Hi All
I am doing a locate <file_name> on my Redhat 7 System. I am unable to get the output. All the keep getting is:
locate: this is not a vlaid slocate database: /var/lib/locate/slocate.db
I may be wrong about this and am completely going on an old memory, which may or may not be correct. I seem to remember the database used by locate is created when the system is booted, thus rebooting the system MAY fix the issue. It's worth a shot if you don't have any other ideas and can reboot the box without too much trouble.
That doesn't make sense, the slocate db is usable by root, but not users? Sounds like a permissions problem to me...
Usually, locate/slocate are updated from cron.
Depending on which locate you're using, it may be at /usr/bin/updatedb, /usr/libexec/update.locatedb, or others...
Being that you're on a Redhat system, try running /usr/bin/updatedb as root to rebuild the file. Then check the permissions.
I am confused... if the update.db is used to locate files on Linux, does that mean any files that I add during the day will not be visible until the slocate.db is run at the end of the day or whenever it is supposed?
I tested it out and actually Ic annot locate the files I created a moment ago as root until I run updatedb. Am I missing something or is there a problem with my machine?
By the way, yes, you do need to update the DB before it'll see any files...
Also, seeing that you are using slocate, there are some things to keep in mind.
slocate stores user permissions to make sure a normal user can't see files they shouldn't... Try doing something like "slocate exec" as a normal user, then execute the same query as root - you'll usually get more matches as root...
Livin Free:
u/s your point about not being able to find the same number of files as a user than as root. But the problem remains... I cannot locate at all as an ordinary user.
The permissions of my slocate.db is 640. Is that the reason of this problem. I do know sometime back I was able to locate as an ordinary user as well. So I don't know why this issue crept up.
>>You can also use the environment variable LOCATE_PATH to set the list of database files to search.
This Env variable is not set. I draw a blank both as root and as myself.
I have 751 permissions set on /usr/bin/slocate/ directory(there is a symlink to slocate which has 777 permissions... this is what I could interpret as I could see ) . U think I should change this to the one as yours. The owner and group are the same as yours.
I was unable to change the mode from 751 to 750... I get a msg
chmod: /usr/bin/locate: operation not permitted.
I am issuing this as root (I am on a vnc xTerm).
thanks for the help