Search for files using locate

The locate command searches a database of filenames in Linux. Unlike the find command, which can find files by permissions, owner, file size, etc, the locate command finds files only by their name. 

This command does not search your system live. Instead, it has its own database that it usually updated once a night or once a week. This means that locate may not find files added since the last database update.

Here is an example:

linux locate command

What if we try to find a file that was recently added? Well, if the database wasn’t updated, we won’t get any result with when using the locate command:

linux locate new file

To rectify this, we need to update the database manually. This can be done using the updatedb command. After the update, we should be able to find the recently added files:

linux updatedb command

Because locate works from a database, it’s usually much faster than find.
Geek University 2022