Chapter 15: Access Linux File Systems
Hello there! Welcome to my blog post where I'll share my experience with the RH124 course end-of-chapter lab for Chapter 15: Access Linux File Systems. In this lab, I had the opportunity to explore the file-system hierarchy and learn how to identify a directory and the device where it's stored. Moreover, I delved into accessing the contents of file systems by adding and removing file systems in the file-system hierarchy. One of the most valuable skills in Linux is searching for files quickly and efficiently, and I got to practice using the find and locate commands. Specifically, I mounted a local file system and locate specific files on that file system. So, join me as I take you through my journey of exploring the Linux file system!
Question 1: On the serverb
machine as the root
user, identify the UUID for the /dev/vdb1
device, and mount it by using its UUID on the /mnt/freespace
directory.
Solution:
To complete the task of identifying the UUID for the /dev/vdb1
device and mounting it by using its UUID on the /mnt/freespace
directory, I first logged into the serverb
machine as the root
user using the ssh
command followed by the sudo -i
command. Next, I used the lsblk -fp /dev/vdb
command to check the UUID of the /dev/vdb1
device. This helped me to identify the UUID for the device.
Then, I created the /mnt/freespace
directory using the mkdir
command. With the directory in place, I used the mount
command along with the UUID that I had identified earlier to mount the device on the /mnt/freespace
directory. Specifically, I used the command mount UUID="f33ab7cc-a526-49a7-878c-c57700ce245d" /mnt/freespace
to mount the device by using its UUID.
To confirm that the device had been successfully mounted, I used the lsblk -fp /dev/vdb
command again to check the status of the device. This allowed me to verify that the device had been mounted on the /mnt/freespace
directory as intended.
Question 2: Generate a disk usage report for the /usr/share
directory. Save the result in the /mnt/freespace/results.txt
file.
Solution:
To generate a disk usage report for the /usr/share
directory and save the result in the /mnt/freespace/results.txt
file, I used the du
command followed by the file path of the directory that I wanted to generate the report for. Specifically, I used the command du /usr/share
. This command generated the disk usage report for the specified directory.
To save the output to a file, I used the output redirection operator >
to redirect the output of the command to the /mnt/freespace/results.txt
file. Specifically, I used the command du /usr/share > /mnt/freespace/results.txt
. This saved the output of the command to the specified file, allowing me to access the report at a later time.
Question 3: Locate all the files that match the rsyslog.conf
keyword, and store the result in the /mnt/freespace/search1.txt
file.
Solution:
To locate all the files that match the rsyslog.conf
keyword and store the result in the /mnt/freespace/search1.txt
file, I used the locate
command. Before using the locate
command, I updated the database by using the updatedb
command. This helped to ensure that the locate
command would be able to find all the relevant files.
To locate the rsyslog.conf
file, I used the locate rsyslog.conf
command. This command searched the updated database for all files that match the specified keyword and returned their file paths. To store the result in the /mnt/freespace/search1.txt
file, I used the output redirection operator >
to redirect the output of the command to the specified file. Specifically, I used the command locate rsyslog.conf > /mnt/freespace/search1.txt
.To confirm that the command had worked as intended, I used the cat
command to view the contents of the /mnt/freespace/search1.txt
file. This allowed me to verify that the command had located the desired files and saved the output to the specified file. With this approach, I was able to quickly and easily locate all files that matched the rsyslog.conf
keyword and store the result in the /mnt/freespace/search1.txt
file for future reference.
Question 4: Store the search result of all files in the /usr/share
directory that are greater than 50 MB and less than 100 MB in the /mnt/freespace/search2.txt
file.
Solution:
To store the search result of all files in the /usr/share
directory that are greater than 50 MB and less than 100 MB in the /mnt/freespace/search2.txt
file, I used the find
command. The find
command is used to search for files in a directory based on different criteria.
To specify the size criteria for the search, I used the -size
option and specified a range of greater than 50MB and less than 100MB using the +50M
and -100M
arguments. The output of the find
command was then redirected to the /mnt/freespace/search2.txt
file using the output redirection operator >
.
The full command I used was: find /usr/share -size +50M -size -100M > /mnt/freespace/search2.txt
To confirm that the command had worked as intended, I used the cat
command to view the contents of the /mnt/freespace/search2.txt
file. This allowed me to verify that the command had located all files in the /usr/share
directory that matched the specified size criteria and saved the output to the specified file.
Question 5: Return to the workstation
system as the student
user.
Solution:
To return to the workstation
system as the student
user, I used the exit
command twice. The first exit
command logged me out of the root shell, which should be the serverb
machine, and returned me to the serverb
machine as the student user. The second exit
command logged me out of the serverb machine and returned me to the student
user shell on the workstation
machine.
Conclusion
The Access Linux File Systems lab provided a great opportunity to learn about managing file systems in Linux. I was able to identify a directory in the file-system hierarchy and the device where it is stored, access the contents of file systems by adding and removing file systems in the file-system hierarchy, and search for files on mounted file systems with the find and locate commands. These skills are essential in managing files and directories in Linux, and I believe this lab has further improved my Linux proficiency. I would like to hear from you, my readers. Have you ever encountered challenges managing file systems in Linux? What strategies did you employ in resolving the challenges? Feel free to share your thoughts and experiences in the comments section below.