The find command is the cornerstone of file searching in Linux β a recursive filesystem traversal tool that filters files by name, type, size, time, permissions, ownership, and more. Unlike locate, which queries a prebuilt index, find walks the live filesystem in real time, making it accurate but slower on large trees. The critical mental model: every flag is a test that filters which files are passed to actions (-exec, -delete, -print), and tests are combined with implicit AND by default β so understanding precedence and short-circuit evaluation is essential for writing correct, efficient commands.
What This Cheat Sheet Covers
This topic spans 15 focused tables and 152 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
Table 1: Core Name and Path Matching
Name and path matching are the most common entry points for any find invocation. These tests filter files based on their basename or full path, with both case-sensitive and case-insensitive variants available.
| Command | Example | Description |
|---|---|---|
find /var/log -name '*.log' | Match basename against a shell glob pattern; case-sensitive. Always quote the pattern to prevent shell expansion. | |
find ~ -iname 'readme*' | Case-insensitive version of -name; matches README.md, Readme.txt, etc. | |
find . -path '*/tests/*.py' | Match against the full path (not just basename); / is allowed in the pattern. | |
find . -ipath '*/src/*.c' | Case-insensitive full-path match; useful on case-folded filesystems. |