16

My locate command doesn't work, but I found out I had to run updatedb. However, upon invoking that command, bash says bash: updatedb: command not found. What should I do?

Strawberry
  • 1,132
  • 4
  • 15
  • 27
  • Either updatedb is not installed, either it's not in your $PATH variable. When running updatedb, you must do it as root or with sudo. – petrus Oct 30 '10 at 21:38
  • You could look for updatedb with "find" find / -name updatedb -print –  May 18 '13 at 17:10

5 Answers5

16

It was not installed and not in the directories listed by natxo, but I found a solution to install it. Thank you for the lead guys!

http://www.nicecabbage.com/2009/08/install-locate-and-updatedb-on-centos-and-debian/

In root: apt-get install locate

Strawberry
  • 1,132
  • 4
  • 15
  • 27
  • ?? apparently I have not explained it properly. In a debian system *with* updatedb installed, using dpkg -S has told me what package it belonged to. That is why I wrote you needed the locate package, which is what you have done. Glad you found it on your own, though. – natxo asenjo Oct 30 '10 at 21:56
  • 1
    For CentOS/RHEL, it's yum -y install mlocate. – music2myear Sep 26 '13 at 19:12
10

I think you need to install the locate program. In a debian lenny system, the /usr/bin/updatedb file is a symlink to /etc/alternatives/updatedb which is a symlink to /usr/bin/updatedb.findutils.

Using dpkg -S you can find what package a file belongs to:

$ dpkg -S /usr/bin/updatedb.findutils 
locate: /usr/bin/updatedb.findutils

So I think you need to install locate and then run updatedb as root.

Edit: yes, you need the locate package. In the file /usr/share/doc/findutils/NEWS.Debian.gz you can read:

locate is no longer included in the findutils package. It has been split off to a separate package "locate".

and then in /usr/share/doc/findutils/changelog.Debian.gz, on the changelog on 11 nov 2007:

Split off locate/updatedb to a separate package.

natxo asenjo
  • 5,739
  • 2
  • 26
  • 27
5

In order for your locate command to work properly, install locate from apt and then run the command updatedb.

sudo apt install locate
sudo updatedb
navule
  • 166
  • 1
  • 2
  • on newer ubuntu versions install is not enough, there is no executable updatedb, but there is updatedb.findutils and updatedb.findutils – user1660210 Apr 21 '21 at 14:38
2

Must of the command that must be run as root are not in the user's $PATH so just run:

$ sudo updatedb

and it should work.

Gopoi
  • 547
  • 5
  • 21
0

You have to invoke 'updatedb' with administrative privileges. As far is I remeber, findutils are part of a standard Debian distribution /installation, so have a look at /etc/updatedb.conf and /etc/cron.daily/(s)locate.

If nothing's broken, the built of a fresh updatedb [locate database] is a daily cronjob, so you dont'have to worry about this anyway

C_B
  • 1