Friday, May 8, 2009

locate and updatedb on CentOS

If you have a CentOS 5.x box and locate doesn't work. Try this:

sudo yum install mlocate
sudo /etc/cron.daily/mlocate.cron

The first line will install the locate and updatedb commands. It will also setup a cron job to re-index your disk once a day. The second line runs that cron job immediately, so you can start using the locate command right away.

Now you can easily find files on your system. Just use the locate command.

$ locate mlocate.cron
$ locate updatedb

Thanks to my friend Peter Stephan for educating me on the locate command. I don't know how I got along without it.