Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How locate command works [closed]

When I run locate test.rb on ubuntu 12.04 from /home/user/ruby, It display all the files in system ending with test.rb except test.rb in /home/user/ruby.

enter image description here

From http://www.linfo.org/locate.html I read that locate command only returns files for which user has access permission, I created this file I have full permission then why locate is not displaying it's path.

like image 976
Cody Avatar asked Mar 18 '26 17:03

Cody


2 Answers

You need to read the documentation to the end, update the locate db is necessary:

sudo updatedb

From the documentation that you have linked:

Because the database is not updated immediately, recently created files and directories might not show up when searching for them with locate or slocate. Fortunately, however, it is a simple matter to update the database manually, although it might take a few minutes. Manual updating can be accomplished by logging in as the root user (i.e., administrative user), such as by using the su (i.e., substitute user) command, and then issuing the following command:

updatedb

like image 151
hek2mgl Avatar answered Mar 20 '26 05:03

hek2mgl


In fact locate uses a database which is usually periodically updated and which is system-wide. This database can be updated manually by running, with adequate permissions, the command updatedb - as the man page for locate says: "locate can never report files created after the most recent update of the relevant database."

like image 26
user3112185 Avatar answered Mar 20 '26 07:03

user3112185



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!