Basics
Find files with specific extension in current directory
find . -type f -name '*.txt'
Find directories
find . -type d
Find empty files
find . -type f -empty
Find files larger than 1 megabyte
find . -type f -size +1M
Find files smaller than 10 megabytes
find . -type f -size -10M
Find files with exact size of 2004 bytes
find . -type f -size 2004c
Size:
k
kilobytes (1024 bytes)M
megabytes (1024 kilobytes)G
gigabytes (1024 megabytes)T
terabytes (1024 gigabytes)
Actions
Execute command on each file found
find . -type f -name '*.txt' -exec wc -l {} \;
Remove empty directories
find . -type d -empty -delete
Find and delete empty files
find . -empty -type f -delete
File Permissions and ownership
Find files owned by current user
find / -type f -user $USER
Find files not owned by current user
find . -type f -not -user $USER
Find files writable by current user (not owned by the user)
find / -writable -not -user $(id -un) \( -type d -or -type f \) -not -path "/proc/*" -not -path "/sys/" 2>/dev/null
Find files with SUID bit set
find / -type f -user root -perm -4000 -print
find / -type f -perm -u=s 2>/dev/null
Find files with SGID set
find / -type f -group root -perm -2000 -print
Find both SUID and SGID files
find / -type f -perm -4000 -o -perm -2000 -print