Red Hat System Administration I
Note
If you plan to take the RHCSA exam, then use the following approach to maximize the benefit of this Comprehensive Review: attempt each lab without viewing the solution buttons or referring to the course content. Use the grading scripts to gauge your progress as you complete each lab.
Mount a file system and locate files based on different criteria.
Outcomes
Mount an existing file system.
Find files based on their file name, permissions, and size.
If you did not reset your workstation and server machines at the end of the last chapter, then save any work that you want to keep from earlier exercises on those machines, and reset them now.
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 rhcsa-rh124-review5
Specifications
Log in to the
serverbmachine as thestudentuser and switch to therootuser.Identify the unmounted block device that contains an XFS file system on the
serverbmachine. Mount the block device on the/review5-diskdirectory.Find the
review5-pathfile. Create the/review5-disk/review5-path.txtfile that contains a single line with the absolute path to thereview5-pathfile.Find all the files that the
contractor1user and thecontractorgroup own. The files must also have the640octal permissions. Save the list of these files in the/review5-disk/review5-perms.txtfile.Find all files with a size of 100 bytes. Save the absolute paths of these files in the
/review5-disk/review5-size.txtfile.
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 ~]#Identify the unmounted block device that contains an XFS file system on the
serverbmachine. Mount the block device on the/review5-diskdirectory.Identify the unmounted block device that contains the
XFSfile system.[root@serverb ~]#
lsblk -fsNAME FSTYPE LABEL UUID MOUNTPOINT ...output omitted... vdb1 xfs7694653c-45f6-4749-bd87-f2f69c37daa7└─vdb ...output omitted...From the preceding output, the
vdb1block device contains theXFSfile system, which is not mounted on the system.Create the
/review5-diskdirectory.[root@serverb ~]#
mkdir /review5-diskMount the
vdb1block device on the/review5-diskdirectory.[root@serverb ~]#
mount /dev/vdb1 /review5-diskVerify that the
vdb1block device is mounted on the/review5-diskdirectory.[root@serverb ~]#
df -ThFilesystem Type Size Used Avail Use% Mounted on ...output omitted... /dev/vdb1 xfs 2.0G 47M 2.0G 3% /review5-disk ...output omitted...
Find the
review5-pathfile. Save its absolute path in the/review5-disk/review5-path.txtfile.Find the
review5-pathfile. Redirect all error messages to the/dev/nullspecial file.[root@serverb ~]#
find / -iname review5-path 2>/dev/null/var/tmp/review5-pathNote the absolute path to the
review5-pathfile from the preceding output.Use the
vim /review5-disk/review5-path.txtcommand and save the absolute path to thereview5-pathfile. The following example shows the expected content of the/review5-disk/review5-path.txtfile.[root@serverb ~]#
cat /review5-disk/review5-path.txt/var/tmp/review5-path
Find all files that the
contractor1user and thecontractorgroup own. The files must have640octal permissions. Save the absolute paths of these files in the/review5-disk/review5-perms.txtfile.Find all the files that the
contractor1user and thecontractorgroup own and that have640octal permissions. Redirect all the errors to the/dev/nullspecial file.[root@serverb ~]#
find / -user contractor1 \-group contractor -perm 640 2>/dev/null/usr/share/review5-permsOnly the
/usr/share/review5-permsfile meets the criteria of the precedingfindcommand. Note the absolute path to thereview5-permsfile.Use the
vim /review5-disk/review5-perms.txtcommand and save the absolute path of thereview5-permsfile. The following example shows the expected content of the/review5-disk/review5-perms.txtfile.[root@serverb ~]#
cat /review5-disk/review5-perms.txt/usr/share/review5-perms
Find all the files with a size of 100 bytes. Save the absolute paths of these files in the
/review5-disk/review5-size.txtfile.Find all the files with a size of exactly 100 bytes. Redirect all the errors to the
/dev/nullspecial file.[root@serverb ~]#
find / -type f -size 100c 2>/dev/null/usr/share/licenses/ethtool/LICENSE /usr/share/doc/libuser /usr/share/doc/plymouth/AUTHORS ...output omitted... /opt/review5-size ...output omitted...The preceding output might vary depending on the number of files that match the size criteria in your system. Note the absolute paths to all the files from the preceding output.
Use the
vim /review5-disk/review5-size.txtcommand and save the absolute path of the files from the preceding output. The following example shows the expected content of the/review5-disk/review5-size.txtfile.[root@serverb ~]#
cat /review5-disk/review5-size.txt...output omitted... /opt/review5-size ...output omitted...Return to the
workstationsystem as thestudentuser.[root@serverb ~]#
exitlogout [student@serverb ~]$exitlogout Connection to serverb closed. [student@workstation ~]$