Red Hat Linux 6.2: The Official Red Hat Linux Getting Started Guide | ||
---|---|---|
Prev | Chapter 14. Working with Files and Directories | Next |
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 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.
More about locate | |
---|---|
To learn more about locate, read the locate man page (type 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.
More about cron | |
---|---|
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:
Have more than one operating system on our machine, and switch between them -- causing us to halt and restart our Red Hat Linux system;
Shutdown and turn off our machine at the end of the day.
This might mean that cron rarely has a chance to update the slocate database, which is used to catalogue locations of files. But we can just update the database manually. Let's give it a try.
First, su to root (type su in at the prompt, then type your rootpassword).
Now, at the shell prompt, type:
updatedb |
After perhaps a few minutes, the slocate database will be current.