Mencari file (lagi)

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


Mencari file di direktori aktif (current directory)


find . -iname bla-bla-bla

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 dan folder yang namanya mengandung kata catatan

sudo find . -iname "*catatan*"

Mencari file di direktori lain


find /path/to/folder/ -iname bla-bla-bla

Mencari semua file atau folder yang namanya mengandung kata fox di direktori /usr/lib/firefox

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


locate mencari file berdasarkan nama.

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.
— from man locate


locate [OPTION]... PATTERN...
locate -b apa-yang-dicari

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.
— from man which


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.
— from man whereis


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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s