SOLUTION COMPREHENSIVE 5: MOUNTING FILESYSTEMS AND FINDING FILES
In this review, you will mount a file system and locate files based on different criteria.
##OUTCOMES
You should be able to:
• Mount an existing file system.
• Find files on the basis of the file name, permissions and size.
##BEFORE YOU BEGIN
Log in to workstation
as student
using student
as the password.
On workstation
, run lab rhcsa-rh124-review5 start to start the comprehensive
review. This script creates the necessary file system, user accounts and group accounts.
[student@workstation ~]$ lab rhcsa-rh124-review5 start
##INSTRUCTIONS
Accomplish the following tasks on serverb
to complete the exercise.
• On serverb
, a block device containing the XFS
file system exists but is not yet mounted.
Determine the block device and mount it on the /review5-disk directory. Create the /
review5-disk directory, if necessary.
• On serverb
, locate the file called review5-path. Create a file named /review5-
disk/review5.txt that contains a single line consisting of the absolute path to the
review5 file.
• On serverb
, locate all the files having contractor1
and contractor
as the owning
user and group, respectively. The files must also have the octal permissions of 640. Save
the list of these files in /review5-disk/review5-perms.txt.
• On serverb
, locate all files 100 bytes in size. Save the absolute paths of these files in /
review5-disk/review5-size.txt.
-
On serverb, mount the idle block device containing the
XFS
file system on the /review5-
disk directory.
 1.1. From workstation
, open an SSH session to serverb
as student
.
[student@workstation ~]$ ssh student@serverb
...output omitted...
[student@serverb ~]$
 1.2.
Use the lsblk -fs command to determine the idle block device containing the XFS
file system.
[student@serverb ~]$ lsblk -fs
NAME FSTYPE LABEL UUID MOUNTPOINT
...output omitted...
vdb1 xfs 3d97c5ef-23e7-4c1c-a9be-d5c475b3d0d5
└─vdb
...output omitted...
From the preceding output, note that the vdb1
block device contains the XFS
file
system, which is not mounted on any directory.
 1.3.
Use the sudo mkdir command to create the /review5-disk directory as the
superuser. When the sudo command prompts you for a password, give the password
student.
[student@serverb ~]$ sudo mkdir /review5-disk
[sudo] password for student: student
 1.4.
Use the sudo mount command to mount the vdb1 block device on the /review5-
disk directory as the superuser.
[student@serverb ~]$ sudo mount /dev/vdb1 /review5-disk
 1.5.
Verify that the vdb1
block device is successfully mounted on the /review5-disk
directory.
[student@serverb ~]$ df -Th
Filesystem Type Size Used Avail Use% Mounted on
...output omitted...
/dev/vdb1 xfs 2.0G 47M 2.0G 3% /review5-disk
...output omitted...
2. On serverb
, locate the file named review5-path. Record its absolute path in the /
review5-disk/review5-path.txt text file.
 2.1.
Use the find command to locate the file called review5-path. Redirect all the
errors of the find command to /dev/null. This redirection allows you to discard any
error from the output of the find command.
[student@serverb ~]$ find / -iname review5-path 2>/dev/null
/var/tmp/review5-path
Note the absolute path to the review5-path file from the preceding output.
 2.2.
Create the /review5-disk/review5-path.txt text file. Record the absolute
path to the review5-path file, as determined in the preceding step, in the /
review5-disk/review5-path.txt text file. You may use the sudo vim /
review5-disk/review5-path.txt command to create the text file. Type :wq!
from the command mode in vim to save the changes and quit from the file. The
following output shows the content of the /review5-disk/review5-path.txt
text file.
/var/tmp/review5-path
3.
On serverb
, locate all files having contractor1
and contractor as the owning user
and group, respectively. The files must also have the octal permissions of 640
. Record the
absolute paths to all of these files in the /review5-disk/review5-perms.txt text file.
 3.1.
Use the -user, -group, -perm options with the find command to locate all the
files that have the owning user, owning group and octal permissions of contractor1
,
contractor
and 640
, respectively. Redirect all the errors of the find command to /
dev/null.
[student@serverb ~]$ find / -user contractor1 \
-group contractor \
-perm 640 2>/dev/null
/usr/share/review5-perms
Note the absolute path to the review5-perms file from the preceding output. The
/usr/share/review5-perms file is the only one that meets the criteria of the
preceding find command.
 3.2.
Create the /review5-disk/review5-perms.txt text file. Record the absolute
path to the only file (review5-perms) that has the owning user, owning group
and octal permissions of contractor1
, contractor
and 640
, respectively, as
determined in the preceding step, in the /review5-disk/review5-perms.txt
text file. You may use the sudo vim /review5-disk/review5-perms.txt
command to create the text file. Type :wq! from the command mode in vim to save
the changes and quit from the file. The following output shows the content of the /
review5-disk/review5-perms.txt text file.
/usr/share/review5-perms
4.
On serverb
, locate all the files of 100 bytes in size. Record the absolute paths to all of these
files in the /review5-disk/review5-size.txt.
 4.1.
Use the -size option with the find command to locate all the files that are of
100 bytes in size. Redirect all the errors of the find command to /dev/null.
[student@serverb ~]$ find / -size 100c 2>/dev/null
/dev/disk
/run/initramfs
/etc/lvm
/etc/audit
/etc/sos.conf
/usr/lib/python3.6/site-packages/dnf/conf
/usr/lib/python3.6/site-packages/ptyprocess
/usr/share/licenses/ethtool/LICENSE
/usr/share/doc/libuser
/usr/share/doc/python3-cryptography/docs/x509
/usr/share/doc/python3-jinja2/ext
/usr/share/doc/plymouth/AUTHORS
/usr/share/vim/vim80/macros/maze/main.aap
/usr/libexec/plymouth
/opt/review5-size
The preceding output may vary in your system depending on the number of files
of 100 bytes in size in your system. Note the absolute paths to all the files from the
preceding output.
 4.2.
Create the /review5-disk/review5-size.txt text file. Record the absolute
paths to all the files of 100 bytes in size, as determined in the preceding step, in the
/review5-disk/review5-size.txt text file. You may use the sudo vim /
review5-disk/review5-size.txt command to create the text file. Type :wq!
from the command mode in vim to save the changes and quit from the file. The /
review5-disk/review5-size.txt text file should contain the absolute path to
the review5-size file among other paths.
...output omitted...
/opt/review5-size
...output omitted...
 4.3.
Log out of serverb
.
[student@serverb ~]$ exit
logout
Connection to serverb closed.
[student@workstation ~]$
##Evaluation
On workstation
, run the lab rhcsa-rh124-review5 grade command to confirm success
of this exercise.
[student@workstation ~]$ lab rhcsa-rh124-review5 grade
##Finish
On workstation
, run lab rhcsa-rh124-review5 finish to complete the comprehensive
review. This script deletes the file system, user accounts, and group accounts created during the
start of the comprehensive review and ensures that the environment on serverb
is clean.
[student@workstation ~]$ lab rhcsa-rh124-review5 finish
This concludes the comprehensive review.