RHCSA Rapid Track
Reset the root password on a system.
Outcomes
Reset the lost
rootuser password.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command runs a start script that determines whether the servera machine is reachable on the network. It also resets the root password to a random string and sets a higher time-out for the GRUB2 menu.
[student@workstation ~]$ lab start boot-resetting
Instructions
Reboot
servera, and interrupt the countdown in the boot-loader menu.Locate the icon for the
serveraconsole, as appropriate for your classroom environment, and then open the console.Send Ctrl+Alt+Del to your system by using the relevant button or menu entry.
When the boot-loader menu appears, press any key to interrupt the countdown, except Enter.
Edit the rescue kernel boot-loader entry, in memory, to abort the boot process just after the kernel mounts all the file systems, but before it hands over control to
systemd.Use the cursor keys to highlight the rescue kernel entry (the one with the rescue word in its name).
Press e to edit the current entry.
Use the cursor keys to navigate to the line that starts with
linux.Remove any
console=options from the line.Important
If you do not remove the
console=options from the GRUB entry for the rescue kernel, the root prompt might be started on the wrong console and you might not be able to access it easily.Press End to move the cursor to the end of the line.
Append a space followed by the
rd.breakoption to the end of the line.Note
If it is difficult for you to see the text in the console, then consider changing the resolution when editing the kernel line in the boot loader entry.
To change the console resolution, add either
video=640x480orvga=askon the line that starts with thelinuxword, afterrd.break. For most consoles, a resolution of640x480is enough. By usingvga=ask, you can choose a more suitable resolution for your environment.Press Ctrl+x to boot by using the modified configuration.
Press Enter to perform maintenance. At the
sh-5.1#prompt, remount the/sysrootfile-system as read/write, and then use thechrootcommand to enter achrootjail at/sysroot.switch_root:/#
mount -o remount,rw /sysroot...output omitted... switch_root:/#chroot /sysrootsh-5.1#Change the
rootpassword back toredhat.sh-5.1#
passwd rootChanging password for user root. New password:redhatBAD PASSWORD: The password is shorter than 8 characters Retype new password:redhatpasswd: all authentication tokens updated successfully.Configure the system to automatically perform a full SELinux relabeling after booting. This step is necessary because the
passwdcommand re-creates the/etc/shadowfile without an SELinux context.sh-5.1#
touch /.autorelabelType
exittwice to continue booting your system as usual. The system runs an SELinux relabel operation, and then reboots automatically. When the system is up, verify your work by logging in asrootat the console.