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
/etc/cron.daily/mlocate.cron
$ locate updatedb
/etc/updatedb.conf
/usr/bin/updatedb
/usr/share/man/man5/updatedb.conf.5.gz
/usr/share/man/man8/updatedb.8.gz


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

Enjoy!

Post a Comment