Updated: 3 November 2026 · Applies to: Linux, GNU findutils, grep and plocate
Linux has several command line tools for finding files, and each fits a different situation: find for an exact, up to the minute search by name or attribute, locate for a fast search of an indexed database, grep for finding files by what is inside them, and which/whereis for finding where a command itself lives.
1. find: search by name, type or attribute
find walks a directory tree you give it and tests every file and directory against the conditions you specify, so it is always accurate, including files created seconds ago, but slower than an indexed search on a large filesystem. A basic search by name, starting from your home directory:
find ~ -iname "*.log"
-iname matches case insensitively. Other common tests include -type f for files only, -type d for directories only, -size +100M for files over 100MB, and -mtime -7 for files modified in the last 7 days.
2. locate: search an indexed database instantly
locate answers from a prebuilt database instead of scanning the disk, so it is much faster, at the cost of missing anything created since the database was last updated. On current Debian and Ubuntu releases the package is plocate, a faster, security hardened replacement for the older mlocate:
apt install -y plocate
On AlmaLinux, Rocky Linux or RHEL, the same package is available directly:
dnf install -y plocate
Build or refresh the database, then search:
updatedb locate nginx.conf
Most distributions also run updatedb automatically once a day.
3. grep: find files by their contents
grep searches inside files for a pattern, so it is the right tool when you remember text from a file but not its name or location. To search recursively under a directory:
grep -Ri "connection refused" ~/logs
-R searches the directory recursively, and -i ignores case. To print only the matching file names, not the matching lines, add -l:
grep -Rli "connection refused" ~/logs
4. which: find the binary a command runs
which shows the full path of the executable your shell would run for a given command name, searching your PATH:
which find which locate
5. whereis: find a command, its source and its man page
whereis goes further than which: alongside the binary, it also looks for the command's source package and manual page:
whereis find whereis locate
A faster modern alternative to find: fd
fd is a newer search tool with simpler syntax than find, color coded output, respects .gitignore by default, and runs noticeably faster on large trees. On Debian and Ubuntu the package is fd-find and the command is fdfind, since the plain fd name was already taken by another package:
apt install -y fd-find
A basic search:
fdfind nginx.conf
On AlmaLinux, Rocky Linux or RHEL via EPEL, the package is also called fd-find, but there the command installs as plain fd:
dnf install -y epel-release dnf install -y fd-find
fd nginx.conf