Master the “find” command in Linux: A practical cheatsheet

The find command is one of the most powerful tools in a developer’s or sysadmin’s arsenal, but many of us barely scratch the surface of what it can do. It’s not just for searching; it’s for analysis and automation.

This guide is a comprehensive, visua…


This content originally appeared on DEV Community and was authored by Shakhzhakhan Maxudbek

The find command is one of the most powerful tools in a developer's or sysadmin's arsenal, but many of us barely scratch the surface of what it can do. It's not just for searching; it's for analysis and automation.

This guide is a comprehensive, visual cheatsheet to help you master it, broken down into three parts: finding files, searching by metadata, and taking action on your results.

Part 1: Finding Files by Name & Type

Let's start with the basics. Here are the most common ways to find files and directories by their name or extension.

Copy-paste version:

Find files by name (case-sensitive):

find /path/to/search -type f -name "myfile.txt"

Find files by name (case-insensitive):

find /path/to/search -type f -iname "myfile.txt"

Find all directories named 'logs':

find / -type d -name "logs"

Find files by extension (e.g., all .conf files):

find /etc -type f -name "*.conf"

Part 2: Finding by Time & Size

Now for a more advanced use case: searching by metadata. This is incredibly useful for finding old logs, large downloads, or just analyzing disk space.

Copy-paste version:

Find files modified in the last 24 hours:

find /var/log -type f -mtime -1

Find files modified MORE than 7 days ago:

find /home/user/Downloads -type f -mtime +7

Find files larger than 100MB:

find / -type f -size +100M

Find empty files or directories:

find /path/to/search -empty

Part 3: Taking Action (-exec, -delete)

This is where the find command becomes a superpower. So far, we've only searched for files. Now, let's learn how to perform actions on them.

Copy-paste version:

Execute a command on each found file (e.g., change permissions):

find /path/to/app -type f -name "*.sh" -exec chmod +x {} \;

Periodically delete old backup files (older than 3 days):
WARNING: The -delete action is final. Use with caution!

find /var/backups -name "*.zip" -type f -mtime +3 -delete

Find all cache files and ask for confirmation before deleting (y/n):

find / -type f -name "*.cache" -ok rm {} \;

Downloadable version:

Source & downloads:

You can find the original PNG version of this cheatsheet in the original post:

How to use the find command in Linux


This content originally appeared on DEV Community and was authored by Shakhzhakhan Maxudbek


Print Share Comment Cite Upload Translate Updates
APA

Shakhzhakhan Maxudbek | Sciencx (2025-09-05T10:47:59+00:00) Master the “find” command in Linux: A practical cheatsheet. Retrieved from https://www.scien.cx/2025/09/05/master-the-find-command-in-linux-a-practical-cheatsheet/

MLA
" » Master the “find” command in Linux: A practical cheatsheet." Shakhzhakhan Maxudbek | Sciencx - Friday September 5, 2025, https://www.scien.cx/2025/09/05/master-the-find-command-in-linux-a-practical-cheatsheet/
HARVARD
Shakhzhakhan Maxudbek | Sciencx Friday September 5, 2025 » Master the “find” command in Linux: A practical cheatsheet., viewed ,<https://www.scien.cx/2025/09/05/master-the-find-command-in-linux-a-practical-cheatsheet/>
VANCOUVER
Shakhzhakhan Maxudbek | Sciencx - » Master the “find” command in Linux: A practical cheatsheet. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/09/05/master-the-find-command-in-linux-a-practical-cheatsheet/
CHICAGO
" » Master the “find” command in Linux: A practical cheatsheet." Shakhzhakhan Maxudbek | Sciencx - Accessed . https://www.scien.cx/2025/09/05/master-the-find-command-in-linux-a-practical-cheatsheet/
IEEE
" » Master the “find” command in Linux: A practical cheatsheet." Shakhzhakhan Maxudbek | Sciencx [Online]. Available: https://www.scien.cx/2025/09/05/master-the-find-command-in-linux-a-practical-cheatsheet/. [Accessed: ]
rf:citation
» Master the “find” command in Linux: A practical cheatsheet | Shakhzhakhan Maxudbek | Sciencx | https://www.scien.cx/2025/09/05/master-the-find-command-in-linux-a-practical-cheatsheet/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.