I wish to have the command locate
in ubuntu 12.04 (which is used for finding files. I believe there is such a command but I cannot see it in ubuntu 12.04 Is it part of any package?
2 Answers
sudo apt-get install mlocate
should install the 'locate' command.
mlocate
maintains a database of all your files and is re-indexed once a day by default. If you want it to re-index immediately then run sudo updatedb
from the command line.
If you get a cannot stat
error when you run locate
, then you need to run sudo updatedb
to populate the database, just as if you wanted to re-index immediately.
From Ubuntu 22.04 onwards, mlocate
is a transitional dummy package that installs plocate
, so you can run sudo apt-get install plocate
instead to install plocate
directly.
-
7I believe that the mlocate package installs a mlocate job in /etc/cron.daily which runs updatedb daily.– mfischNov 11, 2012 at 2:20
-
2Just after you do that, if you try to call locate, you will get the following error: "locate: can not stat () `/var/lib/mlocate/mlocate.db': No such file or directory". To solve that, please refer to @enxotib response in: unix.stackexchange.com/questions/26188/… May 12, 2014 at 4:02
-
You probably want to run
sudo updatedb
after installing mlocate, since the search database needs to be optimized for first time use. Apr 10, 2016 at 20:48 -
1If you're on CentOS/RHEL/Amazon Linux, use
sudo yum install mlocate
to install it. Also the same, runsudo updatedb
to initialize the database for the first time.– ADTCMay 6, 2018 at 0:42 -
1Warning: At least on pop_os! 22.04
mlocate
is a transitional dummy package toplocate
, which have some advantages but have fewer features (like--transliterate
) Nov 22, 2022 at 22:57
-
-
1
sudo apt-get install locate
.sudo apt-get install apt-file
and search for the program using apt-file:apt-file search /usr/bin/locate
.locate
is already installed in a standard Ubuntu install anyway, so maybe this doesn't help.locate
that keeps dis-/re-appearing, andplocate
, which (arguably) might be an improved (or the same as)locate
, and there'smlocate
which might be its own thing or just a dummy package forplocate
orlocate
but now seems to be gone, and wasn't there iir aslocate
at some point? aaaack