In this exercise, you search for specific files on mounted file systems by using the find and locate commands.
Outcomes
Search for files with the find and locate commands.
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 fs-locate
Instructions
On the workstation machine, use the ssh command to log in to the servera machine as the student user.
[student@workstation ~]$ ssh student@servera
...output omitted...
[student@servera ~]$Use the locate command to search for files on the servera machine.
Update the locatedb database manually on the server machine.
Use the sudo updatedb command to update the database.
[student@servera ~]$sudo updatedb[sudo] password for student:student[student@servera ~]$
Locate the logrotate.conf configuration file.
[student@servera ~]$ locate logrotate.conf
/etc/logrotate.conf
/usr/share/man/man5/logrotate.conf.5.gzLocate the networkmanager.conf configuration file, ignoring case sensitivity.
[student@servera ~]$ locate -i networkmanager.conf
/etc/NetworkManager/NetworkManager.conf
/etc/dbus-1/system.d/org.freedesktop.NetworkManager.conf
/usr/share/man/man5/NetworkManager.conf.5.gzUse the find command to search in real time on the servera machine according to the following requirements:
List all files in the /var/lib directory that the chrony user owns.
List all files in the /var directory that the root user and the mail group own.
List all files in the /usr/bin directory with a file size that is greater than 50 KB.
List all files in the /home/student directory that changed in the last 120 minutes.
List all the block device files in the /dev directory.
Search for all files in the /var/lib directory that the chrony user owns, with root privilege.
[student@servera ~]$sudo find /var/lib -user chrony[sudo] password for student:student/var/lib/chrony /var/lib/chrony/drift
List all files in the /var directory that the root user owns and that belong to the mail group.
[student@servera ~]$ sudo find /var -user root -group mail
/var/spool/mailList all files in the /usr/bin directory with a greater file size than 50 KB.
[student@servera ~]$ find /usr/bin -size +50k
/usr/bin/iconv
/usr/bin/locale
/usr/bin/localedef
/usr/bin/cmp
...output omitted...List all files in the /home/student directory that changed in the last 120 minutes.
[student@servera ~]$ find /home/student -mmin -120
/home/student/.bash_logout
/home/student/.bash_profile
/home/student/.bashrc
...output omitted...List all block device files in the /dev directory.
[student@servera ~]$ find /dev -type b
/dev/vdd
/dev/vdc
/dev/vdb
/dev/vda3
/dev/vda2
/dev/vda1
/dev/vdaReturn to the workstation machine as the student user.
[student@servera ~]$ exit
logout
Connection to servera closed.
[student@workstation]$This concludes the section.