Home >System Tutorial >LINUX >How To Reset Root Password In Fedora Linux 39, 38, 37, 36

How To Reset Root Password In Fedora Linux 39, 38, 37, 36

Jennifer Aniston
Jennifer AnistonOriginal
2025-03-20 10:32:12328browse

Resetting Your Fedora Root Password: A Step-by-Step Guide

Forgotten your Fedora root password? This tutorial provides clear instructions for resetting or changing it, regardless of your Fedora version. We'll cover two methods, one optimized for Fedora 39 and 38, and another for older versions.

Table of Contents

  • Resetting the Root Password: A Step-by-Step Approach
    • Method 1: Fedora 39 and 38
      • Step 1: Accessing the GRUB Menu
      • Step 2: Entering Emergency Mode
      • Step 3: Resetting the Password
      • Step 4: SELinux Relabeling
      • Step 5: Rebooting
      • Step 6: Logging In
    • Method 2: Fedora 37 and Older Versions
      • Step 1: Accessing the GRUB Menu
      • Step 2: Identifying the ro Parameter
      • Step 3: Modifying the ro Parameter
      • Step 4: Mounting the Root Filesystem
      • Step 5: Resetting the Password
      • Step 6: SELinux Relabeling
      • Step 7: Rebooting
      • Step 8: Logging In
  • Conclusion

Resetting the Root Password: A Step-by-Step Approach

We'll use emergency mode to reset the password. The methods differ slightly depending on your Fedora version.

Method 1: Fedora 39 and 38

This method is verified for Fedora 39 and 38.

Step 1: Accessing the GRUB Menu

Power on your system and repeatedly press ESC to access the GRUB boot menu. Select your Fedora kernel and press 'e' to edit boot parameters.

How To Reset Root Password In Fedora Linux 39, 38, 37, 36

Example GRUB menu (Fedora 38):

How To Reset Root Password In Fedora Linux 39, 38, 37, 36

Step 2: Entering Emergency Mode

Locate the line starting with "linux ($root)/vmlinuz...", navigate to the end (END or CTRL e), and append:

<code>rw init=/bin/bash</code>

How To Reset Root Password In Fedora Linux 39, 38, 37, 36

Press CTRL x or F10 to boot into emergency mode.

Step 3: Resetting the Password

Your root filesystem should be mounted read-write. If not, use: mount -o remount,rw /. Reset the password using:

<code>passwd</code>

or

<code>passwd root</code>

Enter and confirm your new password.

How To Reset Root Password In Fedora Linux 39, 38, 37, 36

Step 4: SELinux Relabeling

To ensure correct security contexts (if SELinux is enabled):

<code>touch /.autorelabel</code>

How To Reset Root Password In Fedora Linux 39, 38, 37, 36

Step 5: Rebooting

Exit single-user mode and initiate the boot process:

<code>exec /sbin/init</code>

How To Reset Root Password In Fedora Linux 39, 38, 37, 36

Allow SELinux relabeling to complete (may take several minutes). Press ESC if only the Plymouth screen appears to monitor progress.

How To Reset Root Password In Fedora Linux 39, 38, 37, 36

Step 6: Logging In

Log in with your new root password.

How To Reset Root Password In Fedora Linux 39, 38, 37, 36

Method 2: Fedora 37 and Older Versions

This method is tested on Fedora 37, 36, and 35, and should work on older versions.

Step 1: Accessing the GRUB Menu (Same as Method 1)

Step 2: Identifying the ro Parameter

Locate the ro parameter in the boot parameters.

How To Reset Root Password In Fedora Linux 39, 38, 37, 36

Step 3: Modifying the ro Parameter

Replace ro with rw init=/sysroot/bin/sh. Ensure a space between rw and init=/sysroot/....

How To Reset Root Password In Fedora Linux 39, 38, 37, 36

Press Ctrl x to enter emergency mode.

Step 4: Mounting the Root Filesystem

In emergency mode:

<code>chroot /sysroot/</code>

How To Reset Root Password In Fedora Linux 39, 38, 37, 36

Step 5: Resetting the Password (Same as Method 1)

Step 6: SELinux Relabeling (Same as Method 1)

Step 7: Rebooting

Exit single-user mode and reboot:

<code>exit</code>
<code>reboot</code>

Monitor SELinux relabeling progress.

How To Reset Root Password In Fedora Linux 39, 38, 37, 36

Step 8: Logging In (Same as Method 1)

Conclusion

Resetting your Fedora root password is achievable through these steps. Remember to always use a strong password and exercise caution when performing these administrative tasks. The images are retained in their original format.

The above is the detailed content of How To Reset Root Password In Fedora Linux 39, 38, 37, 36. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn