This exercise shows the steps required to reset a lost password for the root user. For this exercise, we use the following command to change the root password to a random string.
# pwmake 128 | passwd --stdin root
The next thing is to reboot the server. When you see the GRUB menu press E to edit the current menu entry. Scroll down until the line starting with linux. Press CTRL-E or END to move to the end of the line, and then add the string rd.break.
Press CTRL-X to boot the system.
The rd.break directive interrupts the boot sequence before the root filesystem is properly mounted. Confirm this by running ls /sysroot. The output should look something below.
Remount the root /sysroot filesystem as read-write and change the root directory to /sysroot:
# mount -o remount, rw /sysroot
# chroot /sysroot
Follow by the passwd command to change the root password:
# passwd
Because SELinux is not running, the passwd command does not preserve the context of the /etc/passwd file. To ensure that the /etc/passwd file is labeled with the correct SELinux context, instruct Linux to relabel all files at the next boot with the following command:
# touch / .autorelabel
# passwd
Because SELinux is not running, the passwd command does not preserve the context of the /etc/passwd file. To ensure that the /etc/passwd file is labeled with the correct SELinux context, instruct Linux to relabel all files at the next boot with the following command:
# touch / .autorelabel
No comments:
Post a Comment