Red Hat Enterprise Linux Diagnostics and Troubleshooting
Diagnose and repair file permissions and corrupted files that belong to packages.
Outcomes
You should be able to diagnose and repair file permission issues and corrupted files with the rpm and yum commands.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
[student@workstation ~]$ lab start rpm-changedfiles
This command modifies RPM-managed files on your system.
Instructions
Users on servera are reporting that they cannot use the sudo or ls commands. Identify and resolve the issues that are preventing the commands from working.
Log in to
serveraas thestudentuser and attempt to switch to therootuser with thesudocommand. An error is expected.[student@workstation ~]$
ssh student@servera...output omitted... [student@servera ~]$sudo -ibash: /usr/bin/sudo: Permission deniedInstead, run the
sucommand to switch to therootuser. Enterredhatas the password.[student@servera ~]$
su - rootPassword:redhat[root@servera ~]#Verify that the
sudoandlscommands are not working and view the displayed errors.Attempt to print a message with the
sudocommand.[root@servera ~]#
sudo echo test message-bash: /usr/bin/sudo: cannot execute binary file: Exec format errorAttempt to list the contents of the
rootuser's home directory with thelscommand.[root@servera ~]#
ls -a-bash: /usr/bin/ls: Permission denied
Begin by investigating the
sudocommand. Run therpmcommand to identify which package provides thesudocommand and verify the contents of the package.Determine which package provides the
sudocommand.[root@servera ~]#
rpm -qf /usr/bin/sudosudo-1.8.29-7.el8.x86_64Verify the contents of the
sudopackage.[root@servera ~]#
rpm -V sudoS.5....T. c /etc/sudoers ..5....T. /usr/bin/sudoThe
/etc/sudoersfile is expected to be in the output because entries were added to the file since it was first installed. However, the/usr/bin/sudofile has content and timestamps that differ from when originally installed. The modified executable is expected to be the source of the issue.
Run the
yum reinstallcommand to repair thesudopackage. Verify the package to confirm that the executable file is restored and that thesudocommand works again.Run the
yum reinstallcommand to repair thesudopackage.[root@servera ~]#
yum reinstall sudo...output omitted...Run the
rpmcommand to verify thesudopackage. The/etc/sudoersfile is still expected in the output.[root@servera ~]#
rpm -V sudoS.5....T. c /etc/sudoersVerify that the
sudocommand now works.[root@servera ~]#
sudo echo test messagetest message
Next, resolve the issue with the
lscommand. Run therpmcommand to identify which package provides thelscommand and verify the contents of the package..Determine which package provides the
lscommand.[root@servera ~]#
rpm -qf /usr/bin/lscoreutils-8.30-8.el8.x86_64Verify the contents of the
coreutilspackage.[root@servera ~]#
rpm -V coreutils.M....... /usr/bin/lsThe
Min the output indicates that the permissions, or mode, of the/usr/bin/lsexecutable file changed.
Run the
rpmcommand to restore the permissions of the files in thecoreutilspackage, verify the package, and confirm that thelscommand works again.Run the
rpmcommand to restore the permissions of the files in thecoreutilspackage.[root@servera ~]#
rpm --setperms coreutilsVerify the
coreutilspackage. No output is expected if the verification succeeds.[root@servera ~]#
rpm -V coreutilsVerify that the
lscommand now works.[root@servera ~]#
ls -a. .. .bash_history .bash_logout .bash_profile .bashrc .cshrc .ssh .tcshrc
Exit from the
rootuser shell and confirm that thesudoandlscommands now also work for thestudentuser.[root@servera ~]#
exit[student@servera ~]$sudo ls -a[sudo] password for student:student. .. .bash_history .bash_logout .bash_profile .bashrcReturn to
workstationas thestudentuser.[student@servera ~]$
exit[student@workstation ~]$