Thread: slocate
View Single Post
free's Avatar
Posts: 739 | Thanked: 159 times | Joined on Sep 2007 @ Germany - Munich
#19
We now have
not grep ;p
not locate
not slocate
but the great secure and fast Mlocate

mlocate is a new implementation of locate, a tool to find files files anywhere in the filesystem based on their name, using a fixed pattern or a regular expression. Unlike other tools like find(1), locate uses a previously created database to perform the search, allowing queries to execute much faster. This database is updated periodically from cron.

Several implementations of locate exist: the original implementation from GNU's findutils, slocate, and mlocate. The advantages of mlocate are:

* it indexes all the filesystem, but results of a search will only
include files that the user running locate has access to. It does
this by updating the database as root, but making it unreadable for
normal users, who can only access it via the locate binary. slocate
does this as well, but not the original locate.

* instead of re-reading all the contents of all directories each time
the database is updated, mlocate keeps timestamp information in its
database and can know if the contents of a directory changed without
reading them again. This makes updates much faster and less demanding
on the hard drive. This feature is only found in mlocate.

Either you update the database :
* Through cron (a daily task is installed) or
* Manually by running updatedb (as root)

mlocate will remap your "/usr/bin/locate" and "/usr/bin/updatedb" to point to mlocate binaries.
It creates a new user/group for security reasons.
You can do normal searches:
PHP Code:
locate .mp3 
Or regexp based searches:
PHP Code:
locate -"libosso[^-].*postrm" 
I find it very efficient. I suggest to try it out, I've also put this on my PC and now replaces slocate.

Last edited by free; 2008-02-12 at 12:56.