find

GNU find Cheatsheet #

find is used to search for files in a directory hierarchy based on various criteria.

Basic Usage #

Command/OptionExampleDescription
find /path -name filenamefind /home/user -name document.txtFind files named document.txt in /home/user
find /path -type ffind /home/user -type fFind all regular files in /home/user
find /path -type dfind /home/user -type dFind all directories in /home/user
find /path -size +100Mfind /var -size +100MFind files larger than 100 MB

Advanced Usage #

Command/OptionExampleDescription
find /path -name "*.txt" -exec ls -l {} \;find /home/user -name "*.txt" -exec ls -l {} \;Find .txt files and list details
find /path -mtime -7find /var/log -mtime -7Find files modified in the last 7 days
find /path -user usernamefind /home/user -user johnFind files owned by user john
find /path -perm 644find /home/user -perm 644Find files with permission mode 644

Deletion and Actions #

Command/OptionExampleDescription
find /path -name "*.tmp" -deletefind /tmp -name "*.tmp" -deleteDelete all .tmp files in /tmp
find /path -name "*.log" -exec rm {} \;find /var/log -name "*.log" -exec rm {} \;Delete all .log files in /var/log

This cheatsheet covers essential find commands and options for GNU systems.

find

Explore our comprehensive cheatsheets to enhance your knowledge and efficiency. Each cheatsheet provides detailed command options, examples, and descriptions to help you master various tools and technologies.