Recursively search for files by name, type, size, time, and more.
medium risk
find is the most powerful file search tool on Linux. It supports filtering by name, type, permissions, size, modification time, and more — and can execute arbitrary commands on matches with -exec. Essential for cleanup, auditing, and automation.
| Flag | Meaning |
|---|---|
-name | Match by filename (case-sensitive) |
-iname | Match by filename (case-insensitive) |
-type | Filter by type: f (file), d (dir), l (symlink) |
-mtime | Match by modification time in days |
-size | Match by size (e.g., +100M) |
-exec | Execute command on each match |
-maxdepth | Limit recursion depth |
find /var/log -name '*.log' -mtime +30 -deleteDelete log files older than 30 days · explain & risk-check →find / -perm /4000 -type f 2>/dev/nullFind all SUID binaries (security audit) · explain & risk-check →find . -name '*.tf' -exec grep -l 'aws_s3_bucket' {} \;Find Terraform files referencing S3 · explain & risk-check →find /home -size +100M -type fFind large files in home directories · explain & risk-check →find . -type f -newer reference.txtFiles newer than a reference file · explain & risk-check →Use `-exec cmd {} +` instead of `-exec cmd {} \;` — the `+` variant batches arguments (like xargs), dramatically faster for large result sets.
Reference text is hand-written and may be incomplete — check man find for your version. Test destructive commands on a non-production system first.