How can I view updatedb database content, and then exclude certain files/paths?

Use PRUNENAMES as stated in man updatedb.conf

A whitespace-separated list of directory names (without paths) which should not be scanned by updatedb(8). By default, no directory names are skipped.

The use of

PRUNENAMES=".git .hg .svn"

should do the trick (above line is the standard value on Fedora 18).


You are probably using the GNU findutils version of locate, which doesn't support the PRUNENAMES option. Installing mlocate will provide these configuration options:

apt-get remove locate
mv /etc/updatedb.conf /etc/updatedb.conf-GNU.old
apt-get install mlocate

Now with the mlocate packge you can edit or create /etc/updatedb.conf and add these lines:

PRUNENAMES=".git .bzr .hg .svn"
PRUNEPATHS="/tmp /var/spool /var/cache /media /usr/tmp /var/tmp /sfs /afs /amd /alex /var/backups/rsnapshot /var/mod_pagespeed"
# the paths in `PRUNEPATHS` must be without trailing slashes

Then actualize the database with:

updatedb

You probably can remove the huge old locate database:

rm /var/cache/locate/locatedb

(The mlocate database is stored at /var/lib/mlocate/mlocate.db)

Check out https://apps.ubuntu.com/cat/applications/mlocate/ for more information about the package.

(I spent a ridiculous amount of time trying to solve a similar issue!)


locate / will list all files and directories in the database.