find command
Search for files by name, size, age, type or permissions and act on them.
- Files & directories
- Package findutils
- 11 options · 12 examples
Syntax
find [path…] [tests] [actions]Provided by the findutils package. Run man find for the full manual.
Common options
| Option | What it does |
|---|---|
-name PATTERN | Match the file name (case-sensitive) |
-iname PATTERN | Match the name, ignoring case |
-type f | d|l | Files, directories or symlinks |
-size +N[kMG] | Larger (+) or smaller (-) than N |
-mtime N | Modified N days ago (+N older, -N newer) |
-mmin N | Modified N minutes ago |
-user NAME | Owned by a user |
-perm MODE | Match permissions, e.g. 777 |
-maxdepth N | Descend at most N levels |
-exec CMD {} + | Run a command on the results |
-delete | Delete what matches |
Examples
Find a file by name
find / -name "nginx.conf" 2>/dev/nullName, ignoring case
find . -iname "*.jpg"Only directories
find /var/www -type d -name "cache"Files larger than 100 MB
find / -type f -size +100MFiles modified in the last 7 days
find /home -type f -mtime -7Delete files older than 30 days
find /backups -type f -mtime +30 -deleteFiles with 777 permissions
find /var/www -type f -perm 0777Files owned by a user
find / -user www-data -type fRun a command on each result
find . -name "*.sh" -exec chmod +x {} +Exclude a directory
find . -path ./node_modules -prune -o -name "*.js" -printLimit the depth
find /etc -maxdepth 1 -name "*.conf"Empty files and directories
find . -empty
No example matches. Check the options table or search the guides.
Tips
- Quote patterns like "*.log" so the shell doesn't expand them first.
- Test with
-printbefore you switch to-delete.
find guides
- Find Command in Linux with Practical Examples Linux Commands · Updated Apr 2025
- How to Delete Files Older than 30 days in Linux Linux Commands · Updated Apr 2025
- How to Find Files Containing Specific Strings on Linux Server Linux Commands · Updated Apr 2025
- How to find all files containing specific text in Linux Linux Commands · Updated Apr 2025
- How To Find Modified Files in Last 30 Days in Linux Linux Commands · Updated Apr 2025
- Find All files with 777 permission in Linux Linux Commands · Updated Apr 2025
- Find All files Owned by a Specific User in Unix/Linux Linux Commands · Updated Apr 2025
- How to find files larger than 10MB, 100MB, 1GB in Linux Linux Commands · Updated Apr 2025
