Linux Commands | File Management | find Search Files/Directories

find Command

The find command searches files and directories.

find [path] [-name] [file or directory name] [-type d/f]

Example 1

find /etc/ -name config

Searches for files and directories named config under /etc.

Example 2

find / -name home -type d

Searches from the root directory for entries named home whose type is directory.

Example 3

find / -name passwd -type f

Searches from the root directory for entries named passwd whose type is file.

Advanced find Commands

Example 1

find [path] [-atime] [+n] (-n means within n days)

Searches for files accessed more than n days ago.

Example 2

find [path] [-ctime] [+n] (-n means within n days)

Searches for files created more than n days ago.

Example 3

find [path] [-mtime] [+n] (-n means within n days)

Searches for files modified more than n days ago.

Example 4

find [path] [-amin] [+n] (-n means within n minutes)

Searches for files accessed more than n minutes ago.

Example 5

find [path] [-cmin] [+n] (-n means within n minutes)

Searches for files created more than n minutes ago.

Example 6

find [path] [-mmin] [+n] (-n means within n minutes)

Searches for files modified more than n minutes ago.

Example 7

find [path] [-newer] [file or directory name]

Searches for all files and directories modified after the specified file or directory was created.

Example 8

Multiple commands can be combined into one line.

find / -name a
find / -name b
find / -name a -o -name b