Locate vs mlocate – Key Differences Explained

locate

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?

Best Answer

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.

Related Question