Find Documentation
A comprehensive, gold-standard guide to mastering find for filesystem discovery, audits, automated cleanup workflows, and script integration. find is an essential POSIX utility that provides granular, metadata-driven search capabilities across Linux and Unix filesystems.
Curriculum Architecture
This documentation is structured as a progressive curriculum, taking you from core concepts to advanced production workflows.
1. Introduction
Build the right mental model for find and understand its place in the modern CLI ecosystem.
- What is Find? - Core philosophy and how it traverses filesystems.
- Find vs. Locate vs. Fd - Tool selection for modern environments.
2. Core Syntax
Master the rigorous command structure required by POSIX find.
- Anatomy of Find - Options, paths, and expressions.
- Path Resolution - Handling absolute/relative paths and symlinks.
3. Metadata Filtering
Locate files based on intrinsic OS-level metadata.
- Name and Type - Extension matching and file type filtering.
- Permissions and Ownership - Auditing files by user, group, and octal modes.
4. Time & Size Filtering
Target files based on block usage and chronological lifecycle.
- Time and Timestamps -
mtime,ctime,atime, and relative offsets. - Size Filtering - Bytes, blocks, and human-readable thresholds.
5. Advanced Expressions
Combine filters logically for complex queries.
- Logical Operators - Using
AND,OR,NOTexpressions. - Regex Matching - Leveraging regular expressions within
find.
6. Actions and Exec
Transition from passive discovery to active modification.
- Print and Delete - Safe output handling and built-in deletion.
- Exec and Execdir - Executing external commands securely.
7. Optimization
Scale find across massive storage volumes efficiently.
- Pruning Directories - Skipping irrelevant or slow paths.
- Depth Control - Restricting traversal with
maxdepthandmindepth.
8. Security Auditing
Use find for compliance and system integrity.
- Finding SUID/SGID - Identifying privilege escalation risks.
- Identifying World-Writable Files - Auditing insecure permissions.
9. Real World Workflows
Production-ready patterns for system administrators.
- Log Rotation & Cleanup - Automated retention policies.
- Backup Preparation - Identifying and staging data for archival.
10. Troubleshooting
Diagnose and fix common issues in complex find commands.
- Common Errors - Resolving syntax and permission issues.
- Spaces in Filenames - Handling whitespace and special characters safely.
11. Cheatsheet
High-density reference for daily operations.
- Find Cheatsheet - Core syntax, recipes, and fast-lookup tables.
Always run complex find commands with just -print (or no action) before appending -delete or -exec. Measure twice, cut once.