Bookmark this page

Lab: Mount File Systems and Find Files

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.

In this review, you 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 serverb machine as the student user and switch to the root user.

  • Identify the unmounted block device that contains an XFS file system on the serverb machine. Mount the block device on the /review5-disk directory.

  • Locate the review5-path file. Create the /review5-disk/review5-path.txt file that contains a single line with the absolute path to the review5-path file.

  • Locate all the files that the contractor1 user and the contractor group own. The files must also have the 640 octal permissions. Save the list of these files in the /review5-disk/review5-perms.txt file.

  • Locate all files with a size of 100 bytes. Save the absolute paths of these files in the /review5-disk/review5-size.txt file.

  1. Log in to the serverb machine as the student user and switch to the root user.

    [student@workstation ~]$ ssh student@serverb
    ...output omitted...
    [student@serverb ~]$ sudo -i
    [sudo] password for student: student
    [root@serverb ~]#
  2. Identify the unmounted block device that contains an XFS file system on the serverb machine. Mount the block device on the /review5-disk directory.

    1. Identify the unmounted block device that contains the XFS file system.

      [root@serverb ~]# lsblk -fs
      NAME  FSTYPE LABEL UUID                                 MOUNTPOINT
      ...output omitted...
      vdb1  xfs          7694653c-45f6-4749-bd87-f2f69c37daa7
      └─vdb
      ...output omitted...

      From the preceding output, the vdb1 block device contains the XFS file system, which is not mounted on the system.

    2. Create the /review5-disk directory.

      [root@serverb ~]# mkdir /review5-disk
    3. Mount the vdb1 block device on the /review5-disk directory.

      [root@serverb ~]# mount /dev/vdb1 /review5-disk
    4. Verify that the vdb1 block device is mounted on the /review5-disk directory.

      [root@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...
  3. Locate the review5-path file. Save its absolute path in the /review5-disk/review5-path.txt file.

    1. Locate the review5-path file. Redirect all error messages to the /dev/null special file.

      [root@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. Use the vim /review5-disk/review5-path.txt command and save the absolute path to the review5-path file. The following example shows the expected content of the /review5-disk/review5-path.txt file.

      [root@serverb ~]# cat /review5-disk/review5-path.txt
      /var/tmp/review5-path
  4. Locate all files that the contractor1 user and the contractor group own. The files must have 640 octal permissions. Save the absolute paths of these files in the /review5-disk/review5-perms.txt file.

    1. Locate all the files that the contractor1 user and the contractor group own and that have 640 octal permissions. Redirect all the errors to the /dev/null special file.

      [root@serverb ~]# find / -user contractor1 \
      -group contractor -perm 640 2>/dev/null
      /usr/share/review5-perms

      Only the /usr/share/review5-perms file meets the criteria of the preceding find command. Note the absolute path to the review5-perms file.

    2. Use the vim /review5-disk/review5-perms.txt command and save the absolute path of the review5-perms file. The following example shows the expected content of the /review5-disk/review5-perms.txt file.

      [root@serverb ~]# cat /review5-disk/review5-perms.txt
      /usr/share/review5-perms
  5. Locate all the files with a size of 100 bytes. Save the absolute paths of these files in the /review5-disk/review5-size.txt file.

    1. Locate all the files with a size of exactly 100 bytes. Redirect all the errors to the /dev/null special file.

      [root@serverb ~]# find / -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.

    2. Use the vim /review5-disk/review5-size.txt command 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.txt file.

      [root@serverb ~]# cat /review5-disk/review5-size.txt
      ...output omitted...
      /opt/review5-size
      ...output omitted...
    3. Return to the workstation system as the student user.

      [root@serverb ~]# exit
      logout
      [student@serverb ~]$ exit
      logout
      Connection to serverb closed.
      [student@workstation ~]$

Evaluation

As the student user on the workstation machine, use the lab command to grade your work. Correct any reported failures and rerun the command until successful.

[student@workstation ~]$ lab grade rhcsa-rh124-review5

Finish

On the workstation machine, change to the student user home directory and use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish rhcsa-rh124-review5

This concludes the section.

Revision: rh124-9.0-398f302