Find command
From RZWiki
A CLI program available on most Unix and Linux systems; used to search for files and/or directories.
Contents |
Usage Syntax
find path [option] string [[option] string]]...
Common options include;
- -name - find files by name
- -user username - find files owned by the specified user
- -type (d|f|l) - find only files, directories or symbolic links
- -size - find only files equal to, greater or smaller than the specified size
- -perm - find files by permissions
- -mtime days - find files last modified within the specified number of days
- -atime days - find files last accessed within the specified number of days
- -ctime days - find files that last had their permissions changed within the specified number of days
- -mmin minutes - find files last modified within the specified number of minutes
- -amin minutes - find files last accessed within the specified number of minutes
- -cmin minutes - find files that last had their permissions changed within the specified number of minutes
- -ls - display output in long list format (as the ls -dils command would)
- ! [option] - do not find files that match the specified option
Usage Notes
When searching by file name string can be composed of any combination of characters and regular expressions.
As indicated above, multiple options can be used together to refine a search.
This command supports most Shell Expansion Characters
Command Combinations
noinclude/noinclude
To move or copy the files found by find take a look at our Copy Files Found By Find, Move Files Found By Find and Remove Files Found By Find articles
Usage Examples
Find By Name
find . -name *.conf
Find By User
find . -user username
Find By Name User
find . -name *.conf -user apache
Find By Non-existant User
find . -nouser
Find By Type
find . -type d - Only directories
find . -type f - Only files
Find By Size
find directory -size +1024M
find directory -size -600c
- b - for 512-byte blocks (default)
- c - for bytes
- k - for Kilobytes (units of 1024 bytes)
- M - for Megabytes (units of 1048576 bytes)
- G - for Gigabytes (units of 1073741824 bytes)
Find By Day
find . -mtime -1 - Modified in the last 1 day
find . -atime -1 - Accessed in the last 1 day
find . -ctime -1 - Permissions changed in the last 1 day
Find By Minute
find . -mmin -5 - Modified in the last 5 minutes
find . -amin -5 - Accessed in the last 5 minutes
find . -cmin -5 - Permissions changed in the last 5 minutes
Find By Permissions
find . -perm 777 - find all 'world writable' files (permission 777, read, write and execute permissions for user, group and others) in the current directory and it's subdirectories
find . -perm -2 ! -type l -ls - find all 'world writable' files (permission 777, read, write and execute permissions for user, group and others) in the current directory and it's subdirectories, ignore symbolic links and display output in long list format (as the ls -dils command would)
Operators
! - Except
-o - Or
Command Alternatives
For much faster file name only based searching, consider using the locate command. This command searches a database of the file system, updated daily, rather than the file system itself and is much quicker, as long as the files you are searching for existed when the database was last updated.
Linux Usage Notes
With most Linux or Unix commands;
- Non root users may need to prefix commands with the sudo command, for example: sudo chmod 644 *
- Brief help can be displayed using the -h or --help parameter, for example: chmod --help
- A full command manual can be displayed using the man command followed by the command name, for example: man chmod
- Sometimes 'info' pages are used instead of or to provide more information than man pages; for example: info chmod
- Version information can normally be display using the -v, -V or --version parameter, for example: chmod --version. However, this paramater is also frequently used to display verbose output.
noinclude/noinclude
Related Articles
You may find our regular expressions guide useful
Information on other Linux commands
Information on F5 BigIP commands
Information on Cisco commands
Information on Vyatta commands
Information on Extreme commands
Information on Blue Coat SGOS commands
Information on Nokia IPSO commands
(replacing the # with an @) |






