Finding Files/mencari file, dalam tugas ini kita akan membahas bagaimana untuk mencari file di sistem. Hal ini berguna untuk mengetahui dalam situasi ketika anda tidak dapat menemukan file pada sistem, salah satu yang anda buat atau yang di ciptakan oleh orang lain. Oke kita langsung saja menuju ke materinya.
An easy way to search for a file is to use the locate
command. For example, you can find the location of the crontab
file by executing the following command:
locate crontab
Note that the output from the previous example includes files that have "crontab" as part of their name. To find files that are just named "crontab", use the following command:
locate -b "\crontab"
Note: The locate
command makes use of a database that is traditionally updated once per day (normally in the middle of the night). This database contains a list of all files that were on the system when the database was last updated.
As a result, any files that you created today will not normally be searchable with the locate
command. If you have access to the system as the root user (the system administrator account), you can manually update this file by running the updatedb
command. Regular users can not update the database file.
Another possible solution to searching for "newer" files is to make use of the find
command. This command searches the live filesystem, rather than a static database. The find
command isn't part of the Linux Essentials objectives for this lab, so it is only mentioned here. Executeman find
if you want to explore this command on your own or wait for the lab that explores thefind
command.
You may just want to find where a command (or its man pages) is located. This can be accomplished with the whereis
command :
whereis passwd
The whereis
command only searches for commands and man pages, not just any file.
Recall from earlier that there is more than one passwd
man page on the system. This is why you see multiple file names and man pages (the files that end in .gz
are man pages) when you execute the previous command.
Semoga materi ini bermanfaat ya untuk teman-teman yang membutuhkan.