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

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

find

Locate files anywhere in a directory tree by name, type, size, date — and act on them.

grep

Find lines matching a pattern in files or piped input — the workhorse of text search.

ls

List the contents of a directory, with options for hidden files, long format, sorting and more.

More how-to guides

Check disk space in Linux

See how much space is left, and find out what is using it.

Extract a .tar.gz archive

Unpack tar.gz, tar.bz2, tar.xz and zip archives from the command line.

Free a port that is already in use

Find which process holds a port and stop it cleanly.

Find and replace text in files

Replace text in one file or across a whole project, safely.