In a default installation of RHEL7 there is a daily scheduled job called mlocate which updates a database (usually in /var/lib/mlocate/mlocate.db) that contains an indexed entry for every directory and file in the system. The main objective of this database is to speed up searches for files/directories avoiding the usually slow find command. We can manually update that database after modifying the contents of the system with:

# /etc/cron.daily/mlocate    → best way to do it
# updatedb                   → alternative way

The configuration script for updatedb is non-surprisingly /etc/updatedb.conf:

# cat /etc/updatedb.conf
PRUNEFS = “9p afs anon_inodefs auto autofs bdev binfmt_misc cgroup cifs coda configfs cpuset
debugfs devpts ecryptfs exofs fuse fuse.sshfs fusectl gfs gfs2 hugetlbfs inotifyfs iso9660 jffs2
lustre mqueue ncpfs nfs nfs4 nfsd pipefs proc ramfs rootfs rpc_pipefs securityfs selinuxfs sfs
sockfs sysfs tmpfs ubifs udf usbfs”
PRUNENAMES = “.git .hg .svn”
PRUNEPATHS = “/afs /media /mnt /net /sfs /tmp /udev /var/cache/ccache /var/lib/yum/yumdb
/var/spool/cups /var/spool/squid /var/tmp /var/lib/ceph”

The locate command can be used with straight-names, globbing or regex:

# locate passwd                          → shows files/directories with “passwd” anywhere in the fullpath
# locate *passwd                         → shows files/directories that end with “passwd”
# locate ­­regex “.*documentation.*pdf”    → shows matches fitting regex

<< fc & history