Why you can trust ZDNET : ZDNET independently tests and researches products to bring you our best recommendations and advice. When you buy through our links, we may earn a commission. Our process

'ZDNET Recommends': What exactly does it mean?

ZDNET's recommendations are based on many hours of testing, research, and comparison shopping. We gather data from the best available sources, including vendor and retailer listings as well as other relevant and independent reviews sites. And we pore over customer reviews to find out what matters to real people who already own and use the products and services we’re assessing.

When you click through from our site to a retailer and buy a product or service, we may earn affiliate commissions. This helps support our work, but does not affect what we cover or how, and it does not affect the price you pay. Neither ZDNET nor the author are compensated for these independent reviews. Indeed, we follow strict guidelines that ensure our editorial content is never influenced by advertisers.

ZDNET's editorial team writes on behalf of you, our reader. Our goal is to deliver the most accurate information and the most knowledgeable advice possible in order to help you make smarter buying decisions on tech gear and a wide array of products and services. Our editors thoroughly review and fact-check every article to ensure that our content meets the highest standards. If we have made an error or published misleading information, we will correct or clarify the article. If you see inaccuracies in our content, please report the mistake via this form.


How to search for files in Linux from the command line

If you have trouble finding files in your Linux distribution, there's a built-in command line tool that makes your job much easier.
Written by Jack Wallen, Contributing Writer
group of penguins looking around
Mint Images - David Schultz/Getty Images

I've been using Linux for decades and, although the command line is second nature to me, I still opt to use GUI tools because they tend to be far more efficient than their terminal-based counterparts. There is, however, one task for which I always turn to the command line -- and that's finding files. 

Yes, there are plenty of GUI tools available for this purpose and many desktop environments integrate the feature into their application menus. However, I find some of those options aren't great for locating files and their indexing can sometimes lead to system slowdowns. For these reasons I prefer to open a terminal window and locate the file in question.

Also: Two tricks that make using the Linux command line a lot easier

The one drawback to this method is that, unlike when using a GUI, once a file is found, you have to manually open it. The GUI tool will find the file and then allow you to simply click (or double-click) to open it. With the command line option, you'll be presented with the location of the file. Then you'll need to open the associated application and open the file via the application's File > Open menu. However, this manual process is a trade-off I'm willing to accept for the speed and accuracy of the command line tool.

Let me show you how to use the tool. 

How to find a file from the CLI

What you'll need: The only thing you'll need for this task is a running instance of just about any Linux distribution. I use the find command for two reasons: it's installed by default, and it's easy to use. Let me show you how easy it is to find a file in Linux.

1. The basic use of the find command

Open a terminal window from your desktop menu. With the terminal app open, type the syntax for the basic find command:

find -name FILE

In the above command, FILE is the name of the file you're searching for.

Now, let me explain a couple of things. First off, you 'name' to match a pattern. You can use find without name, but it won't find the file you're looking for unless you're in the right directory housing the file. That restriction, of course, is probably of little to no use, so always remember to add -name to the command and it will locate the file in question, regardless of where you've run the command.

Also: Linux is not just for developers and command line pros

Second, FILE is case senstive. If you're looking for a file named MyFile and you use the command find -name myfile, find won't be able to locate the file. Third, the find command will only be able to search for files within directories you have permission to view. If find comes across a directory where you don't have access, you'll receive the Permission Denied error.

2. A trick and a trap

Let's say you're looking for MyFile.txt. You could simply run the command:

find -name MyFile.txt

But what about if you have files named MyFile.txt, MyFile,odt, and MyFile.rtf, and you want to know where they're all located? In that situation, you could use the * wildcard, like so:

find -name MyFile.*

Now, find will search out all instances of MyFile and report back where they are.

However, there's a trap in this trick. Let's say you have MyFile.rtf in your home directory (aka ~/), MyFile.odt in your Downloads directory, and MyFile.txt in your Documents directory. 

If you're in your home directory and you issue the command find -name MyFile.*, the command will find MyFile.rtf in the home directory and stop looking. 

Also: How to install Linux applications from the command line

But if you're in the root directory of your system (aka /), and you run the find command, it will find all three files, with output similar to this:


There's another way around this trap, where you can place the file name in quotes, like so:

find -name "MyFile.*"

Even if you're in your home directory, find will continue searching after it locates the first instance of the file. My advice is to get into the habit of always using quotes for file names.

And that's how easy it is to find files on Linux from the command line. 

Editorial standards