如何安装locate命令?

JVI*_*yer 67 command-line locate

我希望locate在 ubuntu 12.04 中使用该命令(用于查找文件。我相信有这样的命令,但在 ubuntu 12.04 中看不到它是任何包的一部分吗?

Tho*_*ard 97

sudo apt-get install mlocate 应该安装“定位”命令。


mlocate维护所有文件的数据库,默认情况下每天重新索引一次。如果您希望它立即重新索引sudo updatedb,请从命令行运行。

如果cannot stat运行时出现错误locate,则需要运行sudo updatedb以填充数据库,就像您想立即重新索引一样。

  • 我相信 mlocate 包会在 /etc/cron.daily 中安装一个 mlocate 作业,它每天运行 updateb。 (5认同)
  • 在你这样做之后,如果你尝试调用 locate,你会得到以下错误:“locate: can not stat () `/var/lib/mlocate/mlocate.db': No such file or directory”。要解决这个问题,请参考@enxotib 响应:http://unix.stackexchange.com/questions/26188/how-do-i-enable-locate-and-queue-the-database-to-be-built (2认同)