Mencari file (lagi)

Tulisan saya tempo hari ternyata berlanjut. Perkenalan dengan perintah find mengantar saya mengenal tiga perintah lain yang hampir mirip.


find – search for files in a directory hierarchy


find [-H] [-L] [-P] [-D debugopts] [-Olevel] [starting-point...] [expression]
find . -iname blah

Ganti blah dengan nama file atau folder yang ingin dicari.

Contoh 1:

Mencari file atau folder bernama data di dalam folder saat ini.

find . -iname data

Kalau muncul pesan find: xxxxx: Permission denied, tambahkan sudo sebelum perintah find seperti ini:

sudo find . -iname data

Contoh 2:

Mencari semua file atau folder yang namanya mengandung kata catatan

sudo find . -iname "*catatan*"

Contoh 3:

Mencari file di folder lain. Caranya mirip dua contoh sebelumnya, tinggal tambahkan path/to/directory sesuai target lokasi yang diinginkan.

find /path/to/directory/ -iname blah

Misalnya, untuk mencari semua file atau folder yang namanya mengandung kata fox di direktori /usr/lib/firefox, ketik

$ find /usr/lib/firefox -iname "*fox*"


locate – find files by name.
locate reads one or more databases prepared by updatedb and writes file names matching at least one of the patterns to standard output, one per line.


locate [OPTION]... PATTERN...
locate -b blah


Mencari semua file yang namanya mengandung kata catatan

locate -b 'catatan'

locate memang mirip dengan find. Bedanya, locate jauh lebih cepat. Meski begitu, find punya banyak kelebihan dibanding locate (baca di sini).

locate has only one big advantage over find: speed. find, though, has many advantages over locate.


Mencari lokasi program.

which – locate a command.
which returns the pathnames of the files (or links) which would be executed in the current environment, had its arguments been given as commands in a strictly POSIX-conformant shell. It does this by searching the path for executable files matching the names of the arguments. It does not follow symbolic links


which [-a] filename ...
which filename


Mencari lokasi program firefox

$ which firefox


Mirip which tapi lebih lengkap.

whereis – locate the binary, source, and manual page files for a command.
whereis locates the binary, source and manual files for the specified command names. The supplied names are first stripped of leading pathname components and any (single) trailing extension of the form .ext (for example: .c) Prefixes of s. resulting from use of source code control are also dealt with. whereis then attempts to locate the desired program in the standard Linux places, and in the places specified by $PATH and $MANPATH.


whereis [options] [-BMS directory... -f] name...
whereis nama-program


Mencari lokasi file dan program firefox

$ whereis firefox
firefox: /usr/bin/firefox /usr/lib/firefox /etc/firefox /usr/share/man/man1/firefox.1.gz

Selamat mencoba, semoga bermanfaat.

Baca juga:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s