find command in Linux: search for files
Updated November 1, 2026
The find command walks a directory tree and finds files by name, type, size, or time.
Syntax
find [path] [tests] [actions]The first argument is where to look. Then come the tests, and find checks them left to right for every file.
Common cases
find . -name "*.log" # by name, from the current directory down
find . -type d # directories only
find . -size +10M # files larger than 10 megabytes
find . -mtime -1 # changed in the last 24 hours
find . -name "*.tmp" -delete # find and deleteSample output
$ cd /var/log
$ find . -name "*.log"
./alternatives.log
./apt/history.log
./apt/term.log
./bootstrap.log
./dpkg.log
$ ls apt
eipp.log.xz
history.log
term.logHow it works: tests and -exec
-namematches the file name only, not the whole path, and understands the*and?patterns (quote them so find expands the pattern, not the shell). The action-exec command {} \;runs a command for each match, putting the path where{}is.
Try it
Open the sandbox: a real throwaway Linux terminal in your browser. Run the commands above by hand. The container is deleted when you leave, so there is nothing to be afraid of breaking.
Where this is in the book: the chapter Files and directories.
Common mistakes
An unquoted pattern is expanded by the shell, and find gets something other than what you typed. In a directory with two matching files, find . -name *.txt prints find: paths must precede expression and the name of the second file. The worse part: while only one such file is there, the same line works - the shell substitutes that single name and find looks for exactly it, not for a pattern. Quote it every time: find . -name '*.txt'.
-name looks at the file name only, never at the path, and compares the whole name. That is why find . -name "*.log" in /var/log misses apt/eipp.log.xz: the name ends in .xz, not in .log. For a substring write -name "*log*". For a piece of the path there is no slash in a name at all, so use -path "*/apt/*".
find checks its tests left to right, and -delete sits in that row like any other item. find . -delete -name '*.tmp' wipes the whole directory, together with files you never meant to touch: -delete fires on every file before the name test is ever reached. Put the action last: find . -name '*.tmp' -delete. The safe rehearsal is the same line with -print in place of -delete.