Select Page

Locate Files using Terminal

Let’s locate files using the terminal! This is just a cool little trick you can use if you’re doing a bunch of stuff in the terminal, and you don’t want to leave, or you’re just interested in cool terminal tricks. Let’s say you’re looking for a file, anywhere on your machine, but you don’t know exactly where it is. You can install a very cool search package called mlocate (or merging locate).


On Ubuntu/Debian you can run:

sudo apt-get install mlocate

Or if you’re on that Manjaro/Arch life:

sudo pacman -S mlocate


To locate files in the terminal by using mlocate, just type:

locate [name of the file] [directory in which you want to start recursively searching]

If you’re using mlocate for the first time, it’s not gonna work just yet. mlocate is actually a pair of tool bundled into one. The other half of mlocate is called updatedb. So by running updatedb, you’re essentially creating/updating an index so that you can run your search. So any time you want to run a locate command and it’s not giving you the results you are expecting, there’s a good chance your index is outdated, so you can just run updatedb, then run your locate search again, and you should be good to go.

Update your junk by running updatedb then run locate [file] to get your mind blown!

Bonus Tip

If the results of your locate command are crazy long, like… CRAZY long…. too long to view everything in the terminal because your terminal only has a finite history, here’s a tip: You can print the results of ANY command to a text file and save it anywhere by using >. For example:

sudo locate myfile.txt / > ~/Desktop/searchresults.txt

The above command will run a system-wide search for anything matching myfile.txt recursively from the root directory / and print the results to searchresults.txt on the Desktop.

Good luck and have fun! Now that you’ve found the file you’re looking for, perhaps you want to do something cool with it! If you wanna learn more cool stuff you can do in the terminal, check this out.

Check out more articles

Elevate Your Digital Presence with a Top Tampa Web Design Company

If you’re a business owner in Tampa, partnering with a professional web design company can make all the difference. In this article, we’ll explore the benefits of working with a Tampa web design company and how it can elevate your digital presence.

Create a Custom API Endpoint in WordPress

Creating a custom endpoint in WordPress to check for plugin updates involves several steps. This process includes setting up a custom REST API endpoint, creating a function to handle requests to this endpoint, and ensuring that the response contains the necessary...

Deploy WordPress Updates from a Private Repository

To push code to a private repository and trigger a pending WordPress update badge, you need to follow a systematic approach involving version control, continuous integration/deployment, and the appropriate use of WordPress hooks and filters. Here’s a step-by-step...

How to Generate a Ranger Config File

ranger --copy-config=all This will copy all the default config files from /usr/local/lib so you can make edits without messing anything up. Huge shout out to for explaining this and so much more. Took me a...

First Open Source Contribution

Surprise! I genuinely did not plan on making my first ever open source contribution today. In fact, I didn't plan on a lot of things happening this week at all. I recently got an awesome opportunity to work on a site that is being hosted on a platform called Pantheon,...

How to Exclude Specific Posts and Pages from WP_QUERY

For the sake of having something to work with, let's suppose we've got the following query:In this query, inside the $args array, there's a special parameter that allows you to exclude specific posts and pages from the query. This parameter is called post__not_in and...

Configure SSH For Password-less Connections

Preamble I'm slightly embarrassed to admit this, but it was a long time before I figured out how amazing this little file is and how exactly to put it to good use. The file I'm talking about is the SSH config file. By default, when you first connect to a server via...

WordPress Site Stuck in Maintenance Mode

Plugin Error Code 500 During Update While I was updating a WordPress plugin locally, something happened on my local server to trigger a 500 error code as the plugin was updating. On the frontend, I refreshed the page and was greeted with "Briefly Unavailable for...

Creating a WordPress Plugin Downloader

How it Started I was recently tasked with the challenge of creating a WordPress theme generator. The idea being, instead of writing your style.css file from scratch, you'd be able to just answer a few simple questions about how you'd like your theme set up, and those...

Fix Audio on XFCE Chromebook

The Problem After moving from GalliumOS to Xubuntu, I noticed that playing YouTube videos on both Firefox and Chromium would result in decent playback for a few minutes, but suddenly the audio would turn into a solid beeping tone while the YouTube video displayed the...

Looking for a place to host your next project or design?

Use this link to get your first 4 months of WP Engine for free: WP Engine – Plans (With 4 months free)