Usage

$ find [path] [options] [action]

File types

Type Description
-type b block (buffered) special
-type c character (unbuffered) special
-type d directory
-type p named pipe (FIFO)
-type f regular file
-type l symbolic link
-type s socket
-type d door (Solaris)

File sizes

Size Description
-size b 512-byte blocks (default)
-size c Bytes
-size k Kilobytes
-size M Megabytes
-size G Gigabytes

Find files based on size

<aside> 💡 The + and - prefixes signify greater than and less than, as usual.

</aside>

Example Description
$ find / -size -15K find files less than 15 Kilobytes
$ find / -size +15M find files greater than 15 Megabytes
$ find / -size +15K -size -15G find files greater 15 Kilobytes and less than 15 Gigabytes

Find files based on time and date

Example Description
$ find / -mtime +0 find files modified greater than 24 hours ago
$ find / -mtime 0 find files modified between now and 1 day ago
$ find / -mtime -1 find files modified less than 1 day ago (same as -mtime 0)
$ find / -mtime 1 find files modified between 24 and 48 hours ago
$ find / -mtime +1 find files modified more than 48 hours ago
$ find / -mtime 30 find files last modified 30 days ago
$ find / -mtime +30 –mtime -120 find files last modified between 30 and 120 days
$ find / -mmin -30 find files last modified in 30 minutes ago
$ find / -mtime +1w find files last modified more than 1 week ago
$ find / -atime 0 find files last accessed between now and 24 hours ago
$ find / -atime +0 find files accessed more than 24 hours ago
$ find / -atime 1 find files accessed between 24 and 48 hours ago
$ find / -atime +1 find files accessed more than 48 hours ago
$ find / -atime 30 find files last accessed 30 days ago
$ find / -amin -30 find files last accessed 30 minutes ago
$ find / -mtime -1 find files accessed less than 24 hours ago (same as -atime 0)
$ find / -ctime -5h45m find files with file status changed within the last 6 hours and 30 minutes

Options

Option Description
-name find files by name.
-iname like -name, but the match is case insensitive
-type find specific file types.
-size find files by their sizes.
-perm find files by their permissions.
-user find files by their owner.
-group find file based on the group they belong to.
-mtime find files by their modification time.
-atime find files by the time they where accessed.
-ctime find files files based on the time their status were changed.
-regex use regular expressions with find.
-empty find empty files.
-readable find files which are readable by the current user.
-writable find files which are writable by the current user.
-executable find files executable by the current user.
-maxdepth levels of directories to go when searching files.
-minlevels do not search for files at levels less than the specified level.
-not negate an option.

Find files based on permissions

Example Description
$ find . -type f -perm 0667 find the files whose permissions are 667
$ find / -perm /u=s find files with SUID bit set
$ find / -perm /g=s find files with SGID bit set
$ find / -perm /u=r find files with read-only permission
$ find / -perm /u=w find files with write-only permission
$ find / -perm /u=x find files with executable-only permission

Actions

Action Description
-delete delete matching files or directories
-exec execute commands on matching files, for example ls, rm and so on
-fls write the output to a file
-fprint print the full file name into file file
-ls print matched file information for example size, permissions, owner and so on
-ok like -exec but ask the user first. If the user agrees, run the
command
-print print the full file name on the standard output, followed by a newline. If you are piping the output of find into another program and there is the faintest possibility that the files which you are searching for might contain a newline, then you should seriously consider using the -print0 option instead of -print
-print0 print the full file name on the standard output, followed by a null character (instead of the newline character that -print uses). This allows file names that contain newlines or other types of white space to be correctly interpreted by programs that process the find output.
-printf rint format on the standard output, interpreting \\' es capes and %' directives.

Condition flow

| --- | --- | --- |

Find files and perform specif action