What Is the find Command in Linux?¶
Introduction¶
The find command searches directory trees for files that match tests. It is useful for beginners, Linux administrators, DevOps engineers, and RHCSA students because it solves practical terminal tasks.
What the Command Does¶
Use find to work with the specific Linux object it manages. Before changing anything, identify the target and run a read-only check when possible.
Basic Syntax¶
find PATH TEST ACTION
The syntax includes the command, any options, and the target object.
Common Options¶
-name: match a filename pattern.-type: filter by file type.-exec: run a command for each match.
Practical Examples¶
find /etc -name passwd
find /var/log -type f -name "*.log"
find /var -type f -size +100M
find /home -mtime +30 -type f
Verification command:
find /tmp -maxdepth 1 -type f
Example output:
/etc/passwd
When to Use This Command¶
Use find when you need to locate files by name, type, size, owner, or age. It is especially useful for cleanup tasks and finding large files on full filesystems.
Common Mistakes¶
- Forgetting to quote wildcard patterns such as
*.log, causing the shell to expand them too early. - Using
-deletebefore printing and reviewing the matches. - Searching from
/without limiting scope, which can be slow and noisy.
Quick Reference¶
find /etc -name passwd
find /var/log -type f -name "*.log"
find /tmp -maxdepth 1 -type f
Related Guides¶
Summary¶
The find command is safest when you understand the target, choose the right option, and verify the result with a separate command.