101

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?

JVIyer
  • 1,011
  • 2
  • 7
  • 3

2 Answers2

135

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.

muru
  • 207,228
Thomas Ward
  • 78,878
13
sudo apt install plocate

Use this to install locate command in 22.04

plocate is better than mlocate

martinho
  • 277
  • 2
  • 6