Master the `find` command to locate, filter and act on files across a filesystem — fast and safely. 11.11.2025 | reading time: 3 min Imagine a filesystem with millions of files and a single question: where is that orphaned backup or that giant log? The `find` command answers precisely that question by walking directories and returning files that match expressions — names, sizes, ages, permissions — and then lets the user act on the results. When search matters Knowing how to find files matters when disk space is tight, when forensic traces must be located, or when automated cleanup must run safely; `find` is the swiss-army knife for these tasks because it operates on the filesystem level and can combine many tests into one pass. Typical scenarios Use `find` to locate old logs for rotation, to find large media files for archiving, to detect files with insecure permissions, or to prepare a list of paths to feed into other tools; the command is essential for backups, audits and automated maintenance scripts. Search in practice Case: remove application logs older than 30 days but preview before deleting. First list candidates: ```bash find /var/log/myapp -type f -name '*.log' -mtime +30 -print ``` Sample output: ``` /var/log/myapp/access.log.2024-08-01 /var/log/myapp/error.log.2024-07-15 ``` Confirm sizes and then delete safely by using NUL separators: ```bash find /var/log/myapp -type f -name '*.log' -mtime +30 -print0 | xargs -0 -r ls -lh find /var/log/myapp -type f -name '*.log' -mtime +30 -print0 | xargs -0 -r rm -- ``` Tip: replace `rm --` with `echo` on a dry run to avoid accidental loss. Other tricks to wield Combine `-maxdepth`/`-mindepth`, logical operators (`-not`, `-o`, implicit `-and`), and `-prune` to skip directories (for example `.git`), use `-exec ... {} +` to pass multiple files to a single command (efficient), prefer `-print0` with `xargs -0` for names with spaces, use `-delete` only after testing because it removes files in-place, and explore `-perm`, `-user`, `-group`, `-newermt`, `-printf` and `-quit` for precise control. Tools that play well `locate` (with `updatedb`) gives instant name searches from a maintained database, `fd` is a faster, user-friendly alternative, `grep`/`rg` search file contents, `xargs` and `parallel` consume lists from `find`, and `du`/`ls` help inspect sizes — combine them to build safe, powerful flows. What to remember `find` is powerful, but power requires caution: test with `-print` or `echo`, prefer `-exec ... {} +` to avoid per-file forks, always consider NUL-separated output for safety, and build commands iteratively on a small tree before running globally. Next steps Practice by writing maintenance scripts that use `find` in increasingly complex ways — then audit those scripts and add safety checks; deepen system knowledge with certification goals like CompTIA Linux+ or LPIC-1 and consider intensive exam prep at bitsandbytes.academy to accelerate readiness. Join Bits & Bytes Academy First class LINUX exam preparation. linux find command-line scripting files