CSUF LogoCSUF Site Navigation
optics.csufresno.edu

F12 Post-Installation Changes updatedb

Department of Electrical and Computer Engineering
Associate Professor Gregory R. Kriehn
Forums
Wiki
F12 updatedb

locate is a very powerful command in the Linux environment. It allows you to determine the location of a particular file (or any matches it finds) based upon your search string. For example, if you want to know where sudo is located, you could type:
~> locate sudo
In doing so, however, you'll notice an error message about the database not being setup. This is what the updatedb command is used for.

Fedora Core 5 on up now uses mlocate, opposed to slocate. If you are a Linux newbie, that's meaningless to you, but for others of you out there, it is important to note that mlocate does not support the "DAILY_UPDATE" variable in /etc/updatedb.conf. However, the F9 developers (being the good guys that they are), set up a daily cron job in /etc/cron.daily/mlocate.cron. Well, instead of waiting until tomorrow to be able to use the locate, let's update the database now. But before doing so, there is another thing to consider: 
mlocate allows you to prune your search paths, so that if there is a particular directory that you do not wish locate to search in, you can prevent it from doing so. This is done using the "PRUNEPATHS" variable in /etc/updatedb.conf. I have two locations that I do backups on my server with using rsync: a local partition called /backup, and on a remote NFS-mounted RAID 5 server under /mnt/nfs/backup. I do not wish to see duplicates of backed-up files from my home directory, so I'd like to prune these two paths from locate. First, edit /etc/updatedb.conf using sudo:
~> sudo nano /etc/updatedb.conf
Scroll down to "PRUNEPATHS" and add in whatever paths you do not wish locate to search under. Mine looks like:
PRUNEPATHS = "/afs /media /net /sfs /tmp /udev /var/spool/cups /var/spool/squid
/var/tmp /backup /mnt/nfs/backup /mnt/windows"
Save and exit, making sure that everything under "PRUNEPATHS" is all one a single line. Next, update the database (actually, here we will be creating it for the first time):
~> sudo updatedb
Hit enter and wait. Depending upon your CPU speed, it may take a while. Once finished, test locate once again:
~> locate sudo
This time, you should see a number of returns anything containing the search string "sudo". The command sudo is located under /usr/bin/sudo. Notice that it even found /etc/sudoers. Use locate to your advantage!

One last thing to remember is that with a daily cron job, the database will only be updated once a day. If there are some major changes to your file system, and you need see the changes reflected in locate immediately, just run updatedb again using sudo.