RHCSA Rapid Track
Course update
An updated version of this course is available that uses a newer version of Red Hat Enterprise Linux in the lab environment. Therefore, the RHEL 9.0 version of the lab environment will retire on December 31, 2024. Please complete any work in this lab environment before it is removed on December 31, 2024. For the most up-to-date version of this course, we recommend moving to the RHEL 9.3 version.
In this exercise, you 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.Press End to move the cursor to the end of the line.
Append
rd.breakto 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.sh-5.1#
mount -o remount,rw /sysroot...output omitted... sh-5.1#chroot /sysrootChange 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.
This concludes the section.