Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
Try using this command: sudo apt-get install locate. – Evandro Silva Nov 10 '12 at 20:24
For the future: if you're looking for a program and don't know the package, install apt-file: sudo apt-get install apt-file and search for the program using apt-file: apt-file search /usr/bin/locate. – hnasarat Nov 10 '12 at 20:57
In a standard Ubuntu install this often isn't needed - if you type a command on the command-line that Ubuntu doesn't know, it'll often suggest which package to install to get that command. Come to mention it, I think locate is already installed in a standard Ubuntu install anyway, so maybe this doesn't help. – thomasrutter May 28 '13 at 3:15

sudo apt-get install mlocate should install the 'locate' command, or you can install it from here:

Install via the software center

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.

share|improve this answer
I believe that the mlocate package installs a mlocate job in /etc/cron.daily which runs updatedb daily. – mfisch Nov 11 '12 at 2:20
Just 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:… – Ramon Araujo May 12 '14 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. – Igor G. Apr 10 at 20:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.