There will be times when we know a file or directory exists but we won't know where to find it. Searching for a file or directory can be made much easier with the locate command.
With locate, we'll see every related file or directory which matches our search criterion. Let's say we want to search for all files related to the finger command.
locate finger
The locate command uses a database to check for files and directories which match the string finger.
Tip: To learn more about locate, read the locate man page by typing man locate at a shell prompt.
It's a handy command which works very quickly -- as long as the database is up to date. That database is automatically updated on a nightly basis, from cron. What's cron? It's a small program that runs in the background, performing various tasks -- such as updating the locate database -- at regularly scheduled intervals.
Tip: cron is a daemon. Daemons handle tasks in the background. To read the cron man page, type man cron at the shell prompt.
So what happens if we:
This might mean that cron never has a chance to update the locate database. No problem. We can just update the database manually. Let's give it a try.
First, su to root.
Now, at the shell prompt, type:
/etc/cron.daily/updatedb.cron
After a few minutes, the locate database will be current.