Linux Find and Locate Cheat Sheet

Powerful Linux search commands using find, locate, xargs, and metadata filters.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
## Find by Name and Type
Find file by exact name
find /var/log -name 'syslog'

# Search recursively for a specific filename.

Case-insensitive name search
find . -iname '*.jpg'

# Match names regardless of case.

Find directories only
find . -type d -name 'node_modules'

# Restrict results to directories.

## Find by Size and Time
Find files larger than 100 MB
find / -type f -size +100M 2>/dev/null

# Search for large files using size filters.

Find files modified in last 1 day
find . -type f -mtime -1

# Use mtime to find recently modified files.

Find files accessed more than 30 days ago
find . -type f -atime +30

# Identify stale files.

Find files newer than reference file
find . -type f -newer reference.txt

# Compare timestamps using a reference path.

## Find by Permissions and Ownership
Find world-writable files
find /var/www -type f -perm -002

# Audit overly permissive files.

Find files owned by user
find /home -user alice

# Search by owner name.

Find files owned by group
find /srv -group www-data

# Search by group ownership.

Find files with missing user
find / -nouser 2>/dev/null

# Audit orphaned ownership.

## Actions and locate
Delete old temporary files
find /tmp -type f -name '*.tmp' -delete

# Remove matching files directly from find.

Run chmod on matched files
find . -type f -name '*.sh' -exec chmod +x {} +

# Execute a command on each result.

Locate files using database
locate nginx.conf

# Search quickly using updatedb database.

Refresh locate database
sudo updatedb

# Update file index used by locate.

More in Linux Find and Locate

No other published sheets yet.

Recommended next

No recommendations yet.