Find - search for files in a directory hierarchy.
Find all the files with name "joe.txt" in the current directory
find . -name joe.txt
Find all the files under /home/user01 directory with name joe.txt.
find /home/user01 -name joe.txt
find /home/user01 -iname joe.txt (iname to ignore case )
find /home/user01 -iname joe.txt (iname to ignore case )
Find all directories (only directories) with name movies
find / -type d -name movies
Find all files (only files) with name iron-man.avi
find / -type f -name iron-man.avi
Find all doc files in a directory.
find . -type f -name "*.doc"
Find all the files with permission 777:
find . -type f -perm 0777 -print
Find all the SGID bit files with permissions set to 644:
find / -perm 2644
Find all SUID set files:
find / -perm /u=s
Find all Read Only files.
find / -perm /u=r
Find all Executable files.
find / -perm /a=x
Find and remove specific file
find . -type f -name "movie-list.txt" -exec rm -f {} \;
Find and remove a group of files
find . -type f -name "*.avi" -exec rm -f {} \;
Find all files based on user
find /home -user joe
Find all files based on group
find /home -group work
Find last 30 days modified files
find / -mtime 30
Find last 50 days accessed files
find / -atime 50
Find changed files in last hour
find / -cmin -60
Find modified files in last hour
find / -mmin -60
Find all the files which are accessed in last 1 hour.
find / -amin -60
Find all 100MB files
find / -size 100M
Find files bigger then 100M
find / -size +100M
Find files smaller then 100M
find / -size -100M
Find all .avi files with more than 500MB and delete them.
find / -type f -name *.avi -size +500M -exec rm {} \;