Navigation and files

Command find

Find files by name, type, size and more

Linux · Bash examples · commands run on the selected server

When to use find

Use find to select files by metadata within a directory tree. Choose a narrow starting path first and inspect the matches before adding actions that modify or delete files.

Syntax

find [START_PATH] [CONDITIONS]

Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.

Common options and arguments

-name TEMPLATE
Match a case-sensitive name pattern. Quote the pattern.
-type f
Limit search to regular files; d stands for directories.
-mtime +N
Files modified more than N full days ago.

Usage examples

Find project logs

find ./logs -type f -name '*.log'

The quoted wildcard is evaluated by find, not expanded prematurely by the shell.

Find recently modified files

find ./src -type f -mtime -2

Matches are regular files whose modification age is less than two 24-hour periods.

Show files larger than 100 MiB

find ./data -type f -size +100M

The size filter selects files larger than one hundred mebibytes; it does not sum directory sizes.

Notes and limitations

  • Start at the directory you need to avoid scanning the entire server unnecessarily.
  • Inspect the matches before adding -delete or -exec: these actions can modify the matching files.

Common questions and troubleshooting

How do I search names without matching case?

Use -iname instead of -name where supported. Keep the wildcard quoted so the shell does not replace it with local filenames.

Why do some directories produce Permission denied?

The account cannot traverse or read those directories. Search only the intended accessible tree; suppressing errors does not make the results complete.

Further help

Options vary by version and distribution. Check the installed documentation with this command: man find.