Tools Links Login

Beginners Guide to the Linux find Command

If you’ve ever spent time poking around in Linux, you’ve probably found yourself asking, “Where did that file go?” Don’t worry - you’re not alone. Whether you’re trying to track down a misplaced configuration file, a rogue log, or just figure out where something got installed, the Linux find command is your best friend.

The good news is that once you get the hang of it, find can be one of the most powerful tools in your command-line toolbox. The not-so-good news is that at first glance, it can look a bit intimidating. Let’s fix that.

The Basics

The find command does exactly what its name suggests - it finds files and directories based on the criteria you specify. The simplest way to use it is by giving it a starting location and a pattern to look for.

For example, if you want to find a file called notes.txt anywhere under your home directory, you can type:

find ~ -name notes.txt

Here, the tilde (~) tells find to start searching in your home folder, and the -name option tells it to look for files that match the name notes.txt. The command will print the full path to any matching files.

Case Sensitivity

By default, find is case-sensitive. That means if your file is called Notes.txt, the command above won’t find it. To ignore case, you can use -iname instead of -name:

find ~ -iname notes.txt

Now it doesn’t matter if the file is notes.txt, Notes.txt, or even NOTES.TXT - you’ll still find it.

Searching by Type

Sometimes you don’t just want a specific name - you want all files or all directories that match a pattern. You can do that with the -type option.

For example, to find only directories named “backup”:

find / -type d -name backup

And to find only files named “config.json”:

find / -type f -name config.json

In these examples, / tells find to start at the root of the file system. That’s powerful, but be warned - it’ll search through everything, so it might take a while.

Finding Files by Size

Let’s say your disk is filling up, and you want to hunt down large files hogging space. You can do that with the -size option.

For example, to find files larger than 100 megabytes:

find /home -type f -size +100M

The plus sign means “greater than,” and you can also use a minus sign to find smaller files. Sizes can be expressed in kilobytes (K), megabytes (M), or gigabytes (G).

Searching by Modification Time

Another common task is finding files that were recently modified. The -mtime option makes this easy.

If you want to find files changed in the last day, try:

find /var/log -mtime -1

That’s especially handy when you’re troubleshooting and need to see which log files were updated recently. If you replace -1 with +7, you’ll find files older than a week.

Doing Something with the Results

Finding files is useful, but you can take it one step further. The -exec option lets you run a command on each file that find locates.

For example, if you want to delete every .tmp file in your home directory, you could run:

find ~ -type f -name "*.tmp" -exec rm {} \;

Here’s what’s happening: for every file that matches, find runs the rm (remove) command. The {} gets replaced by the filename, and \; marks the end of the command.

Be careful with this - once a file is deleted, it’s gone for good. If you’re not sure what find will match, run it without -exec first to see the list of files.


The find command can seem like a maze of options at first, but once you learn the basics, it becomes second nature. Start simple - search for a file by name. Then build up as you need more power, like filtering by type, size, or date.

Think of find as your command-line detective. It doesn’t care how messy your file system has become; it’ll track down whatever you’re looking for - quietly, efficiently, and with just a few keystrokes.

With a little practice, find becomes second nature. You’ll start using it almost without thinking - like muscle memory for your terminal. Whether you’re cleaning up clutter, exploring your system, or chasing down that one elusive file, find is one of those Linux commands that pays off the more you use it.

A Quick and Handy find Cheat Sheet

Find a file by name find /home -name myfile.txt
Ignore case while searching find /home -iname myfile.txt
Look for directories find / -type d -name projects
Find files bigger than a certain size find /var -type f -size +500M
Find files modified in the last two days find /etc -mtime -2
Remove all temp files from Downloads find ~/Downloads -type f -name "*.tmp" -exec rm {} \;
Run this first to see what would be deleted find ~/Downloads -type f -name "*.tmp"

About this post

Posted: 2025-11-04
By: dwirch
Viewed: 15 times

Categories

Tutorials

Linux

Beginners Guides

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.