Home >System Tutorial >LINUX >How To Reset Root Password In Fedora Linux 39, 38, 37, 36
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
ro
Parameterro
ParameterResetting 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.
Example GRUB menu (Fedora 38):
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>
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.
Step 4: SELinux Relabeling
To ensure correct security contexts (if SELinux is enabled):
<code>touch /.autorelabel</code>
Step 5: Rebooting
Exit single-user mode and initiate the boot process:
<code>exec /sbin/init</code>
Allow SELinux relabeling to complete (may take several minutes). Press ESC if only the Plymouth screen appears to monitor progress.
Step 6: Logging In
Log in with your new root password.
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.
Step 3: Modifying the ro
Parameter
Replace ro
with rw init=/sysroot/bin/sh
. Ensure a space between rw
and init=/sysroot/...
.
Press Ctrl x to enter emergency mode.
Step 4: Mounting the Root Filesystem
In emergency mode:
<code>chroot /sysroot/</code>
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.
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!