Using updatedb and locate in linux


It is very useful to have the locate command in linux. It will search a database of cached file information and can provide the path of a particular file. This is much quicker than trying to perform a lengthy find on a system which can take quite a bit of time.

First build your database cache by using “updatedb”. This is a necessary step before performing the locate command. Next use locate to find a particular file.

[root@computer ~]# locate trayicon | grep egg
/usr/lib/python2.6/site-packages/gtk-2.0/egg/trayicon.so
/usr/share/doc/gnome-python2-libegg-2.25.3/trayicon.py

Using grep is useful if you get a locate result that contains many files. It can be used to narrow it down a bit.