System Administration Guide
Chapter 2, Administering filesystems

Locating files

Locating files

You can locate all files with a specified name, permissions setting, size, type, owner, or last access or modification date using find(C). Use this command to locate seldom-used or excessively large files, files owned by a particular user, temporary files, core files, and any unused a.out files.

The syntax of find is:

find pathname option

pathname is the pathname of the directory to search. The find command searches recursively, downward through all the directories under the named directory, for files that match the criteria specified by option.


NOTE: You must include the -print option for find to display the list of files that match the search criteria.



Finding specific files by name (-name)
For example, to locate and display all files named temp recursively in the /usr directory, enter:

find /usr -name temp -print



Finding files of a certain size (-size)
For example, to locate and print a list of all the files greater than three blocks in size in all the directories (/ and below), enter:

find / -size +3 -print



Finding files by owner (-user)
For example, to find all files in the /work directory owned by olivier, enter:

find /work -user olivier -print



Finding files of a certain type (-type)
For example, to locate all the directories in /usr/spool/uucp, enter:

find /usr/spool/uucp -type d -print



Finding files by permissions (-perm onum)
onum is the octal number used with chmod(C). 
For example, to locate and display all the files in the /usr directory that give all users read, write, and execute permissions (onum is 0777), enter:

find /usr -perm 0777 -print



See also: