Find files very quickly using Locate with Linux

Tired of using the Find command? want something faster? Use locate!!! It’s easy to use.

locate myfile

Would give you all the files found since last indexing.

Locate uses a database containing file indexes. That’s why it is very fast to find files, that’s the good point of this system. The bad point is that the database is not updated everytime you create/move/delete a file. But it’s easy to force updating.

To update the database (as root, that’s why we use sudo):

sudo updatedb

This should take around 10 or 20 seconds to complete.

Then you can start searching:

$ locate bashrc
/etc/bash.bashrc
/etc/skel/.bashrc
/home/user1/.bashrc
/home/user2/.bashrc
/root/.bashrc
/usr/share/base-files/dot.bashrc
/usr/share/doc/adduser/examples/adduser.local.conf.examples/bash.bashrc
/usr/share/doc/adduser/examples/adduser.local.conf.examples/skel/dot.bashrc

That’s the basics on how to use locate.

Please see “man locate” to get more help about how to use locate.

Leave a Reply