Finding files
Linux Command Line Quick Reference
1 min read
Published Aug 18 2026
Guide Sections
Guide Comments
find walks a directory tree and tests each entry against conditions you provide. It can find by name, type, size, age, owner and more.
Find files
find /path -name "*.log"find /path -iname "readme*"find . -type f -name "*.txt"find . -type d -name "cache"find . -type f -size +100Mfind . -type f -mtime -7find . -maxdepth 2 -type f-name is case-sensitive and -iname is case-insensitive. -type f limits results to files and -type d to directories. -size +100M means larger than 100 MiB. -mtime -7 selects files modified less than seven 24-hour periods ago. -maxdepth limits how deeply find descends.
find can perform an action on matches:
Act on matching files
find . -type f -name "*.tmp" -printfind . -type f -name "*.tmp" -deletefind . -type f -name "*.log" -exec gzip {} \;-delete permanently removes matches, so run the same expression with -print first. With -exec, {} represents each matching path and \; terminates the action.
locate filename is faster for simple name searches because it uses a database, but results can be stale. Refresh it with sudo updatedb where the plocate or mlocate package is installed.