Using locate
The locate utility functions in much the same manner as find.
However, it has one distinct advan-tage over find. Here’s the issue: whenever you run a search with find, it manually walks through each directory in the path you specify in the command looking for matching files.
This process can take a really long time, especially if you’re doing a top-down search from the root of the file system.The locate utility, on the other hand, works in a much more efficient way.
Instead of walking the file system each time you run a search, it builds an index of the files in the file system.
To use locate, you must first install the findutils-locate package on your system. With the package installed, an index (named locatedb) of all the files in your file system will be created in /var/log.
This index will be updated each day with the latest changes to the file system. However, you can also manually update the index using the updatedb command from the shell prompt.
Be aware that updatedb does all the legwork for the locate utility; it can take some time to complete and will use up a lot of system resources in the process.
With the index updated, you can search for files by simply entering locate filename at the shell prompt.
No comments:
Post a Comment