Linux 'find' Cheatsheet
A quick reference for the powerful 'find' command in Linux.
Basic Find
Command | Description |
---|---|
find . -name "myfile.txt" |
Find files named 'myfile.txt' in the current directory and subdirectories. |
find /home -name "*.log" |
Find all files ending with '.log' in the /home directory. |
find . -iname "myfile.txt" |
Case-insensitive search for file names. |
Find and Execute
Command | Description |
---|---|
find . -name "*.tmp" -exec rm {} \; |
Find all .tmp files and execute the 'rm' command on them. |
find . -type f -name "*.sh" -exec chmod +x {} \; |
Find all .sh files and make them executable. |
Find by Size
Command | Description |
---|---|
find . -size +100M |
Find files larger than 100 Megabytes. |
find . -size -10k |
Find files smaller than 10 Kilobytes. |
find . -size 0 -delete |
Find and delete empty files. |
Find by Time
Command | Description |
---|---|
find . -mtime -7 |
Find files modified in the last 7 days. |
find . -mtime +7 |
Find files modified more than 7 days ago. |
find . -cmin -60 |
Find files whose status was changed in the last 60 minutes. |
Find by Type
Command | Description |
---|---|
find . -type d -name "mydir" |
Find directories named 'mydir'. |
find . -type f -name "*.conf" |
Find files (not directories) ending with '.conf'. |