Command library / find
find
Search a directory tree for files matching criteria
Walks a directory tree and prints paths matching whatever tests you give it — by name, type, size or modification time. Unlike grep (which looks INSIDE files), find looks at file metadata and the file system itself. The starting path always comes first.
Practice findUsage
Options and flags
pathdirectory to start searching from
-namePATTERNmatch the file name against a glob pattern (case-sensitive)
-inamePATTERNlike -name, but ignores case
-typef|d|lonly files of this type: f = regular file, d = directory, l = symlink
-maxdepthNdo not descend more than N levels
-mtimeNmodified N*24 hours ago; -N means 'less than N days ago'
-sizeN[kMG]file size, e.g. +100M means larger than 100 MB
Examples
find /var/log -name "*.log"Every .log file under /var/log.
find /home -type dOnly directories, no files, under /home.
find / -iname "readme*"Finds README, readme.txt, ReadMe.md — case ignored.
find /etc -maxdepth 1 -type fFiles directly in /etc, not in its subfolders.
find / -mtime -1 -type fEvery file modified in the last 24 hours — a fast first move after a suspected breach.
Common mistakes
Type letters are lowercase only: f (file), d (directory), l (symlink). A capital D is not a recognised type on Linux.