find

find searches for files and directories using search criteria like name, size, type, file owner, creation time, and access time

Syntax

find [-H] [-L] [-P] [-D debugopts] [-Olevel] [path…] [expression]

Example

  • find . -name “*python*” find files by name

  • find . -wholename “*imghdrdata/*python*” match the full path

  • find . -type d find directories

  • find . -type f find files

  • find . -type l find symbolic links

  • find . -size +20M find files larger than a given size

  • find . -size 13k find files of a given size

  • find . -mtime -2 -type d directories modified in the past two days

  • find . -atime -2 -type d directories accessed in the past two days

  • find . -user root find files owned by the root user

  • find . -maxdepth 2 -type d ! -group root find directories not belonging to the root group, at most 2 levels deep

  • find . -type f -perm -o=rwx find files where other has rwx permission

  • find . -type f -perm -ug=rwx ! -perm -o=r find files where user and group have rwx permission, but other does not have r permission

  • find . -type f -perm 600 find files with 600 permissions