How to find files using mlocate


Finding made easy

At one point , some if not all, applications make some changes to their files infrastructure to some degree that a file like a cfg is no longer where it was “some time ago” leading to a broken script or just frustration and lost time searching the documentation. Here comes mlocate into play. It’s one of the simplest and quickest tools for finding the location of files and directories in a Linux-based system.


For Ubuntu/Debian distros:

apt -y install mlocate

For CentOS/RHEL distros:

yum -y install mlocate

Once installed , its database must be updated in order to index all files and directories.



The basic syntax is the following:

locate [options] name

Find a file and a folder with the following names:

locate file1 dir1

Find all files with the extension .tar :

locate "*.tar"

Find all files with the extension .tar and limit the results to 20:

locate -n 20 "*.tar"

Find all files with the extension .tar and pipe the results for scrolling:

locate "*.tar" | less

Find all files with the extension .tar without case-sensitive:

locate -i "*.Tar"

Although mlocate’s database is updated nightly (if the system is ran continuously) recent file changes and additions might not be visible therefore manually updating it is done as so:




Recent Posts