Skip to main content

find Cheatsheet

By Dejan Panovski Updated on Download PDF

Quick reference for common Linux find command patterns

Find searches for files and directories based on name, type, size, time, and permissions. This cheatsheet covers practical find patterns for everyday Linux administration.

Find files and directories by name.

CommandDescription
find . -name "file.txt"Find an exact filename
find . -iname "readme.md"Case-insensitive name search
find /etc -name "*.conf"Find by extension
find . -type d -name "backup"Find directories by name

Filter by Type

Limit results to file system object type.

CommandDescription
find . -type fRegular files only
find . -type dDirectories only
find . -type lSymlinks only
find . -type f -name "*.log"Files with a specific extension
find . -maxdepth 1 -type fSearch current directory only
find . -type f -emptyFind empty files
find . -type d -emptyFind empty directories

Size Filters

Find files by size.

CommandDescription
find . -type f -size +100MLarger than 100 MB
find . -type f -size -10MSmaller than 10 MB
find . -type f -size 1GExactly 1 GB
find /var -type f -size +500MLarge files under /var

Time Filters

Filter by file modification, access, and change times.

CommandDescription
find . -type f -mtime -7Modified in last 7 days
find . -type f -mtime +30Modified more than 30 days ago
find . -type f -atime -1Accessed in last 24 hours
find . -type f -ctime -3Metadata changed in last 3 days
find . -type f -mmin -60Modified in last 60 minutes

Permissions and Ownership

Find files based on permissions and owners.

CommandDescription
find . -type f -perm 644Exact permission match
find . -type f -perm -u+wUser-writable files
find / -type f -user rootFiles owned by user
find /srv -type f -group www-dataFiles owned by group

Excluding Paths

Skip directories from search results.

CommandDescription
find . -path ./node_modules -prune -o -type f -printExclude one directory
find . \( -path ./node_modules -o -path ./.git \) -prune -o -type f -printExclude multiple directories
find . -type f ! -name "*.log"Exclude one filename pattern
find . -type f ! -path "*/cache/*"Exclude by path pattern

Actions (-exec, -delete)

Run commands on matched files.

CommandDescription
find . -type f -name "*.tmp" -deleteDelete matches
find . -type f -name "*.log" -exec gzip {} \;Run command per file
find . -type f -name "*.jpg" -exec mv {} /tmp/images/ \;Move matched files
find . -type f -name "*.conf" -exec grep -H "listen" {} \;Search text in matched files
find . -type f -name "*.log" -exec rm {} +Batch delete (faster than \;)

Safer Bulk Operations

Use null-delimited output for safe piping.

CommandDescription
find . -type f -name "*.txt" -print0 | xargs -0 rm -fSafely remove files with spaces
find . -type f -print0 | xargs -0 ls -lhSafe batch listing
find . -type f -name "*.log" -print0 | xargs -0 du -hSafe size report for matches
find . -type f -name "*.bak" -print0 | xargs -0 -I{} mv "{}" /tmp/backup/Safe batch move

Common Options

Useful flags to remember.

OptionDescription
-nameMatch filename (case-sensitive)
-inameMatch filename (case-insensitive)
-typeFilter by file type
-sizeFilter by size
-mtimeFilter by modification time (days)
-maxdepthLimit recursion depth
-mindepthSkip top levels
-pruneExclude directories
-execExecute command on matches
-emptyFind empty files/directories
-mminFilter by modification time (minutes)
-deleteDelete matched files