Locating Faster

Locating Faster

We’ve talked about the find command. It’s a drive search on steroids. With find, you can locate any file by name, ownership, permissions, etc. It’s powerful and very useful. It can also be very slow.

Because of the speed issue, locate has become my preference for finding files on a massive hard drive. It doesn’t have quite the options available to find, but it’s much, much faster.

That increased speed is the result of cron and the locate database. cron updates the locate database once daily, adding new programs that may have been installed in the iterim. find starts fresh with every search. In other words, locate searches an updated system database while find actually searches the drives. The result is searches that take virtually no time at all to complete with locate.

There is a drawback to locate, though, that seems obvious when you understand its database background. The database itself only gets updated once a day. If you’re like me, you install a fair number of programs. Those programs won’t be updated in the database until the next cron locate update is run. If you’ve installed those programs ten minutes after the cron job has run, you’ll be another 23 hours and 50 minutes without an updated locate file. That is, unless you know today’s GnomeTWEAK.

The updatedb command, when run as root, uses the find program to update the locate database, up to the minute. Talk about system cooperation.

With a simple command and bit of patience, your locating files can be faster and right up to date.

Article Written by