How to Find Files and Directories with the Linux find Command

Published 2026-08-05 · Learn Linux

The find command searches the filesystem for files and directories that match conditions you give it. The classic form is find /path -name "pattern". It is the most flexible way to locate files, because it can filter by name, type, size and modification time — and then run a command on every result.

Find by name

Search a starting directory with -name. The pattern can include wildcards, so *.conf matches every file ending in .conf.

$ find /etc -name *.conf
$ find . -name report.txt

Find directories only with -type

Use -type to filter by file type: f for regular files, d for directories, l for symbolic links. This is how you find every empty folder or all log files in a tree.

$ find /home -type d -name .git

Find by size and age

Conditions combine naturally. Find large files with -size (use +100M for larger than) or old files with -mtime (use +30 for older than 30 days).

$ find /var -size +100M
$ find . -mtime +30 -name *.tmp

Ignore case with -iname

Filesystem names are case-sensitive. Use -iname when you are not sure about the case, so Report.TXT matches a search for report.txt.

$ find . -iname readme*

Run a command on results with -exec

To act on every match, use -exec followed by the command and a literal {} for the file. This deletes every .bak file in the tree:

$ find . -name *.bak -exec rm {} \;

Test carefully — there is no undo. The find reference page documents all tests and actions.

Keep learning

Related guides: The Linux ls Command: List Files Like a Pro · How to Search Files for Text with the Linux grep Command · How to Copy Files and Directories with the Linux cp Command. Read all tutorials on the Learn Linux blog.