Hi Brian,

I personally use 'locate' all the time, and rarely use 'find' if 'locate'
is available.

The major problem I have with find is that it's slow. Even restricting the
search space to a specific directory (as opposed to searching everything
under "/") can be slow. For example, searching my home directory takes a
while, due to the large number of Python virtual envs that I have.

Sometimes searching a specific directory simply does not work with find due
to the presence of symlinks. You have to wait for find to complete (which
might take a while), realize that maybe symlinks are involved (which is not
obvious) and re-run find with -L, hoping it will work.

Searching from the root directory "/" with find is not just slow, but also
clobbers the terminal with "Permission Denied" or "Operation Not Permitted"
errors. You must remember to use 2>/dev/null (hoping that won't hide any
useful errors).

With locate instead you can search the entire filesystem and get your
results in a few milliseconds, without thinking about edge cases.

Also, if you want to always exclude certain filesystems or directories,
with find you have to play with -prune or -xdev or similar, and repeat the
same arguments every time. With locate, you can just edit one configuration
file once and you're done. In my locate configuration I exclude things like
my LXC/LXD containers: I never want results involving those.

Those are the reasons why I wish locate was enabled everywhere, not just
Ubuntu :-)

Hope this helps!


On Wed, May 22, 2019, 20:00 Brian Murray <br...@ubuntu.com> wrote:

> The Ubuntu Foundations team was recently looking at an issue with
> mlocate[1] and the effect it has on all users of Ubuntu. While that
> specific issue is fixable there are also issues[2,3] with keeping
> PRUNEFS and PRUNEPATHS current in updatedb.conf. So we ended up
> questioning the usefulness of installing mlocate by default on systems
> at all. We believe that find is an adequate replacement for mlocate but
> want to hear from you about use cases where it may not be. I'll start
> with a personal example:
>
> "I don't remember (because I need to know so infrequently) where the
> meta-release file is cached on disk by update-manager and use locate to
> find it. The find command itself is inadequate because the cached file
> exists in both /home and /var."
>
> [1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=880507
> [2] http://launchpad.net/bugs/827841
> [3] http://launchpad.net/bugs/1823518
>
> Thanks,
> --
> Brian Murray
>
> --
> ubuntu-devel mailing list
> ubuntu-devel@lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel
>
-- 
ubuntu-devel mailing list
ubuntu-devel@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel

Reply via email to