How to Find Files by Name in Linux
Locate files and directories by exact name or wildcard pattern with find.
Use find when you know something about a path but not where it lives. Combine a start directory, type and name pattern.
Step by step
1 Find an exact file
$ find . -type f -name "config.yml" Searches recursively for that exact filename.
2 Find by extension
$ find . -type f -name "*.log" Keep wildcards quoted so the shell does not expand them first.
3 Ignore case
$ find . -type f -iname "readme*" Matches common capitalization variants.
4 Find directories
$ find /var -type d -name "cache" Use -type d when you need directories.
Tips worth knowing
- Prefer a narrow starting path over `find /`.
- Use -maxdepth 1 when you do not need recursion.
- Quote wildcard patterns.
Frequently asked questions
How do I search for a filename in Linux?
Use `find START -type f -name "NAME"`.
How do I search case-insensitively?
Use `-iname` instead of `-name`.
The commands behind it
Locate files anywhere in a directory tree by name, type, size, date — and act on them.
grepFind lines matching a pattern in files or piped input — the workhorse of text search.
lsList the contents of a directory, with options for hidden files, long format, sorting and more.
More how-to guides
See how much space is left, and find out what is using it.
Extract a .tar.gz archiveUnpack tar.gz, tar.bz2, tar.xz and zip archives from the command line.
Free a port that is already in useFind which process holds a port and stop it cleanly.
Find and replace text in filesReplace text in one file or across a whole project, safely.