find — Search the Filesystem
find is one of the most powerful Linux commands. It searches for files based on almost any criteria.
Basic syntax
find [where] [what] [action]
Find by name
find . -name "*.txt" # .txt files in current dir (recursive)
find / -name "config.php" # Find config.php anywhere
find . -iname "*.TXT" # Case-insensitive
find . -name "log*" # Files starting with 'log'
Find by type
find . -type f # Files only
find . -type d # Directories only
find . -type l # Symlinks only
Find by size
find / -size +100M # Larger than 100MB
find / -size -1k # Smaller than 1KB
find . -size +10M -size -100M # Between 10MB and 100MB
Find by time
find . -mtime -7 # Modified in last 7 days
find . -mtime +30 # Modified more than 30 days ago
find . -newer reference.txt # Newer than reference.txt
Find by permissions
find . -perm 777 # Exact permissions 777
find . -perm -u+x # Owner has execute
find / -perm -4000 # Setuid files
Actions
find . -name "*.log" -delete # Delete found files
find . -name "*.txt" -exec cat {} \; # Run command on each
find . -name "*.sh" -exec chmod +x {} + # Make scripts executable
find . -type f -exec ls -la {} + # List found files
Combining conditions
find . -name "*.log" -size +10M # AND
find . -name "*.log" -o -name "*.tmp" # OR
find . -not -name "*.txt" # NOT