find files with locate in Ubuntu

Published: May 16, 2022

find files with locate in Ubuntu

In this article, we would cover how to find files with locate in Ubuntu. Most of us, usually start with graphics-based Operating System. And, they are pretty easy to comprehend. But, at times, we need to use command-line interface.

And, to use a Command-line interface - we need to know and understand the instructions we have to provide in order for things to work. So, when it comes to finding files through a GUI - it may seem easy. But, when we try to do the same through a Command-line interface - we would get stuck. Because, we may not know the relevant commands.

So, when it comes to finding files in Ubuntu. There are numerous options available. Here, we would cover locate command-line utility.

find files with locate in Ubuntu

locate command mainly looks for the files stored in a database. This database is updated through updatedb command. The data of files which are there in a database is limited through /etc/updatedb.conf configuration file.

So, if the configuration doesn't contain a particular file type then it won't be there. Besides, the same can be said about mount types. Although, locate command could run faster than its alternatives like find command but, we can't say that it would be possible for it to find all the files in a machine.

Apart from that, normal users can't search files accessible by a superuser.

The database is stored in -

/var/lib/plocate/plocate.db

And, it is updated by default. The issue here is, if we add a file to the system. Then, it won't show up through locate until the database gets updated.

To find a file with locate (case-sensitive) -

locate <file_name>

For case-insensitive locate, use -i option -

locate -i <file_name>

with -i option, it doesn't differentiate between upper case and lower case letters.

In conclusion, we have covered here how to find files with locate in Ubuntu. In next article, we would see how it is different from find command-line utility.