strange

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

What des this mean? Is my system compromised?

Thanks in advance.

KS

Is the db actually there? If it is what are the permissions, do you need to be root to access it?

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.

The database is there... I am able to locate as root.

Sounds like a PATH issue. The root PATH envvar has the path to the .DB in it whereas the user that you are looking for it does not.

thanks...but how can i set the envvar PATH to the slocate.db file?
Is this right?
PATH = :/var/lib/slocate/slocate.db
export PATH

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?

Cheers

KS

From the locate man page:

Please post the output of this command when you are root:

echo $LOCATE_PATH

Then su or login as a non-root user and do the same thing. Cut and past the output into your next reply :slight_smile:

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.

640 is what I have...
I have the slocate directory 750, and slocate.db file 640.
Both are owned by root, and their group is "slocate".

The /usr/bin/slocate binary is owned by root, group "slocate".
The binary is Set GID - is yours?

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

Seems to me you should (properly) set your LOCATE_PATH environmental variable first before working on changing permissions, etc.