Linux Redhat lab: Reset the root UserPassword

Опубликовано: 23 Июль 2026
на канале: Le Hoang Long Long
63
1

   • Redhat Lab: Red Hat Certified System Admin...   Link playlist
   • Redhat Lab: Red Hat Certified System Admin...  
2023 05 29 03 45 41

Exercise 11-2: Reset the root User
Password
This exercise should be done on server1.
For this exercise, assume that the root user password is lost or forgotten, and
it needs to be reset.
In this exercise, you will terminate the boot process at an early stage to be
placed in a special debug shell in order to reset the root password.
1. Reboot or reset server1, and interact with GRUB2 by pressing a key
before the autoboot times out. Highlight the default kernel entry in the
GRUB2 menu and press e to enter the edit mode. Scroll down to the line
entry that begins with the keyword “linux” and press the End key to go to
the end of that line:
2. Modify this kernel string and append “rd.break” to the end of the line. It
should look like:
3. Press Ctrl+x when done to boot to the special shell. The system mounts
the root file system read-only on the /sysroot directory. Make /sysroot
appear as mounted on / using the chroot command:
4. Remount the root file system in read/write mode for the passwd
command to be able to modify the shadow file with a new password:
5. Enter a new password for root by invoking the passwd command:
6. Create a hidden file called .autorelabel to instruct the operating system
to run SELinux relabeling on all files, including the shadow file that was
updated with the new root password, on the next reboot:
7. Issue the exit command to quit the chroot shell and then the reboot
command to restart the system and boot it to the default target.
Depending on the storage speed, the system might take a few minutes to
complete the relabeling and return to a fully functional state.