Red Hat Enterprise Linux Diagnostics and Troubleshooting
Reset a root password.
Outcomes
You should be able to reset a root password without having another form of root access to a machine.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
[student@workstation ~]$ lab start boot-rootpw
This command changes your system's root password and increases the grub2 boot menu timeout value.
Instructions
A colleague installed a new servera system, but does not remember the root password. The server is otherwise configured properly, but the documentation does not include the password.
You are asked to reset the root password to redhat.
Important
For this exercise, assume that you do not have ssh access to servera, and that the student account on servera does not have full sudo access. Use a direct virtual console connection to servera. Obtain access to the servera console with an appropriate method for your classroom environment.
Open a console to your
serverasystem, log in as thestudentuser, and reboot the system. Press any key exceptEnterto pause the GRUB menu timer when it appears, and force the system to pause the boot sequence during execution of the initial ramdisk.From the console, log in to your
serverasystem as thestudentuser and run therebootcommand.servera login:
studentPassword:student[student@servera ~]$rebootPress any key except
Enterto pause the GRUB menu timer when it appears.Highlight the default entry, and press e to edit it.
Scroll down to the line that starts with
linux, press Ctrl+e to jump to the end of the line, remove allconsole=settings (if any), and appendrd.break.Press Ctrl+x to boot with these modified settings.
Change the root password to
redhat, force SELinux to relabel all files during the next boot, and reboot the system.Remount the file system on
/sysrootwith read-write capabilities.switch_root:/#
mount -o remount,rw /sysrootChange the root directory to
/sysroot.switch_root:/#
chroot /sysrootSet the
rootpassword toredhat.sh-4.2#
echo "root:redhat" | chpasswdForce SELinux to relabel all files during the next boot.
sh-4.2#
touch /.autorelabelReboot your system by typing
exittwice.sh-4.2#
exitexit switch_root:/#exitexit
Log in to the console as the
rootuser with the passwordredhat.servera login:
rootPassword:redhat[root@servera ~]#