The locate command searches a database of filenames that Linux maintains. 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:
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:
To avoid this, we need to update the database manually. This is done using the updatedb command. After the update, we should be able to find recently added files:
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:
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:
To avoid this, we need to update the database manually. This is done using the updatedb command. After the update, we should be able to find recently added files:
NOTE – because locate works from a database, it’s typically much faster than find.
Post a Comment