47

I wanted to install the command locate, which is available via sudo apt-get installmlocate.

However, I first ran sudo apt-get installlocate which seems to have installed something else.

Typing the command locate <package> however seems to call upon mlocate.

What is the package locate, and can (should) it be safely removed?

1
  • 2
    I believe mlocate was the replacement for the original locate, But That was 15 years ago, and probably, one package is an alias or referer to the other. There is another variant, "slocate" which observed a file's visibility based on user permissions, but I haven't see. That in a long time
    – Otheus
    Commented Mar 30, 2016 at 17:26

2 Answers 2

60

The locate package is the implementation of locate from GNU findutils. The mlocate package is another implementation of the same concept called mlocate. They implement the same basic functionality: quick lookup of file names based on an index that's (typically) rebuilt every night. They differ in some of their functionality beyond basic usage. In particular, GNU locate builds an index of world-readable files only (unless you run it from your account), whereas mlocate builds an index of all files but only lets the calling user see files that it could access. This makes mlocate more useful in most circumstances, but unusable in some unusual installations where it isn't run by the system administrator (because mlocate has to be setuid root), and a security risk.

Under Debian and derivatives, if you install both, locate will run the mlocate implementation, and you need to run locate.findutils to run the GNU implementation. This is managed through alternatives. If you have both installed, they'll both spend time rebuilding their respective index, but other than that they won't conflict with each other.

3
  • 17
    You neglected to mention mlocate's main feature, from which it gets its name ("merging locate"): It provides a version of updatedb that reuses its old index to improve update performance by only querying lists of files/subdirectories for directories where the ctime has changed.
    – ssokolow
    Commented Jul 17, 2018 at 4:08
  • "GNU locate builds an index of world-readable files only" are you sure? I found names of a lot of files via locate as regular user, where I had no permissions to in the end
    – rubo77
    Commented Jan 1, 2022 at 22:48
  • @rubo77 Your locate is probably mlocate and not GNU locate. Commented Jan 2, 2022 at 8:35
11

mlocate is a newer implemenation of locate. Once you install mlocate it

will change the /usr/bin/locate binary to point to mlocate via the alternatives mechanism.

That is why you get mlocate behaviour if you install in that order.

Details can be found here

1
  • 2
    In fact, I never installed mlocate, but on my Ubuntu 16.04 system, /usr/bin/locate -> /etc/alternatives/locate -> /usr/bin/mlocate Commented Nov 8, 2017 at 4:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .