Basic Format
find [path] [expression]Key Expressions
-name pattern | Search for a file by its name | |
-iname pattern | Case insensitive search | |
-user name | Search for files owned by user 'name' | |
-group name | Search for files belonging to group 'name' | |
-mtime n | Search for files modified n*24 hours ago | |
-size n[cwbkMG] | Search for files of size n.
Add suffixes for specific units c=bytes, w=two-byte words, b=512 bytes, k=kilobytes, M=megabytes, G=gigabytes | |
-perm mode | Search for files with specific permissions | |
-type [bcdpflsD] | Search for files of a specific type b=block, c=character, d=directory, p=pipe f=normal file, l=symbolic link, s=socket, D=door | |
-exec command {} \; | Execute 'command' on each file found | |
-delete | Delete files found (use cautiously) |
Examples
find / -name filename | Find a file called 'filename' in root directory | |
find /home/user -name '*.txt' | Find all .txt files in /home/user directory | |
find / -user username | Find all files owned by 'username' in root directory | |
find / -type f -empty | Find all empty files in root directory | |
find / -type d -empty | Find all empty directories in root directory | |
find / -name '*.tmp' -size +500k | Find .tmp files larger than 500k in root directory | |
find / -type f -perm 0666 | Find files with permissions 0666 in root directory | |
find / -name '*.bak' -type f -delete | Find and delete all .bak files in root directory | |
find / -type f -mtime -7 | Find files modified within the last 7 days in root directory | |
find / -name '*.jpg' -exec mv {} /tmp \; | Find all .jpg files and move them to the /tmp directory |