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 lab, you reset the root password on a system, recover from a misconfiguration, and set the default boot target.
Outcomes
Reset a lost password for the
rootuser.Diagnose and fix boot issues.
Set the default
systemdtarget.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command prepares your environment and ensures that all required resources are available.
[student@workstation ~]$ lab start boot-review
Instructions
On the
serverbmachine, reset the password toredhatfor therootuser.Locate the icon for the
serverbmachine console 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 the Enter key.
Use the cursor keys to highlight the rescue kernel boot-loader entry (the one with the rescue word in its name).
Press e to edit the current entry.
Use the cursor keys to navigate the line that starts with the
linuxtext.Press Ctrl+e to move the cursor to the end of the line.
Append the
rd.breaktext to the end of the line.Note
If it is difficult for you to see the text in the console, 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 enter the maintenance mode.
At the
sh-5.1prompt, remount the/sysrootfile system as writable, and then use thechrootcommand for the/sysrootdirectory.sh-5.1#
mount -o remount,rw /sysroot...output omitted... sh-5.1#chroot /sysrootSet
redhatas the password for therootuser.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 perform a full SELinux relabeling after booting.
sh-5.1#
touch /.autorelabelExit the
chrootenvironment and thesh-5.1prompt. After the file system is relabeled, the system prompts to enter maintenance mode. However, if you wait, then it completes the reboot and shows the boot-loader menu.
In the boot-loader menu, select the default kernel boot-loader entry. The system fails to boot, because a start job does not complete successfully. Fix the issue from the console of the
serverbmachine.Boot the system into emergency mode. Reboot the
serverbmachine by sending 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.
Use the cursor keys to highlight the default boot-loader entry.
Press e to edit the current entry.
Use the cursor keys to navigate the line that starts with the
linuxtext.Press Ctrl+e to move the cursor to the end of the line.
Append the
systemd.unit=emergency.targettext to the end of the line.Press Ctrl+x to boot by using the modified configuration.
Log in to emergency mode.
Give root password for maintenance (or press Control-D to continue):
redhat[root@serverb ~]#Remount the
/file system as writable.[root@serverb ~]#
mount -o remount,rw /...output omitted...Mount all file systems.
[root@serverb ~]#
mount -amount: /olddata: can't find UUID=4d5c85a5-8921-4a06-8aff-80567e9689bc.Edit the
/etc/fstabfile to remove or comment out the incorrect line that mounts the/olddatamount point.[root@serverb ~]#
vim /etc/fstab...output omitted... #UUID=4d5c85a5-8921-4a06-8aff-80567e9689bc /olddata xfs defaults 0 0Update the
systemddaemon for the system to register the changes in the/etc/fstabfile configuration.[root@serverb ~]#
systemctl daemon-reloadVerify that the
/etc/fstabfile configuration is correct by attempting to mount all entries.[root@serverb ~]#
mount -aReboot the system and wait for the boot to complete. The system should now boot normally.
[root@serverb ~]#
systemctl reboot
Change the default
systemdtarget on theserverbmachine for the system to automatically start a graphical interface when it boots.No graphical interface is installed on the
serverbmachine. Set only the default target, and do not install the packages.Log in to the
serverbmachine as thestudentuser and switch to therootuser.[student@workstation ~]$
ssh student@serverb...output omitted... [student@serverb ~]$sudo -i[sudo] password for student:student[root@serverb ~]#Set the
graphical.targetas the default target.[root@serverb ~]#
systemctl set-default graphical.targetRemoved /etc/systemd/system/default.target. Created symlink /etc/systemd/system/default.target → /usr/lib/systemd/system/graphical.target.Verify that the correct default is set.
[root@serverb ~]#
systemctl get-defaultgraphical.targetReturn to the
workstationmachine as thestudentuser.[root@serverb ~]#
exitlogout [student@serverb ~]$exitlogout Connection to serverb closed.
This concludes the section.