Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I was testing out the locate command for finding things. If I type: locate <randomShortString>
it will generally return multiple hits as there are some dir or filename which happen to include <randomShortString>
when I tried to use it to find files that I had created myself it failed
I had created files indep.npz and indep.txt yesterday and when I type locate indep
It returns nothing. So I though maybe the db had not been updated so I manually issued the command: sudo updatedb
but locate indep still returns nothing despite the files clearly being present. So, can anyone explain this ?
On a related note the man page for updatedb lists the EXIT_STATUS of updatedb as 0 on success, 1 on error.
How do I determine the EXIT_STATUS for a call to a command ? It clearly isn't being sent to stdout as I'm seeing neither 0 nor 1 when I call updatedb. Seeing the exit status might allow me to figure out if it is the updatedb or the locate that is not behaving as expected.
To see the exit status of any command in shell, just after it terminates, use:
Code:
echo $?
Not sure why locate doesn't find your files after you updated the db... Are you sure of the file names?
Okay so the EXIT_STATUS of the updatedb is 0 indicating success, but the locate command still fails to find my files. The EXIT_STATUS of the call to locate is 1 which could indicate no matches or an error. So it seems that it is the locate command that is at fault but I cant figure out why. I am using Ubuntu and the files in question are in my home directory. When installing Ubuntu I did specify that my home dir should be encrypted, could this be the source of the problem ?
you can check the man page of locate and updatedb to see how they are working. Especially updatedb -v will print the files it found. and also you can check the config file.
My user dir is /home/oisin and the tree command shows clearly that it contains many files and subdirs (most of which have existed since Linux was installed) yet the locate command only returns one result: '/home/oisin' when clearly it should also contain an entry for each of the objects below /home/oisin
Anyone have any ideas why this is happenning? At the moment all I can thing is that it has something to do with the fact that I specified that my home dir should be encrypted when installing Linux but neither locate nor updatedb mentions having any problems with encrypted dirs.
There might be directories/filesystems to be excluded in updatedb's configuration. Locations like /media or /run/media are often excluded by default, as are filesystems usually used on removable media (like UDF). Check if this is the case for you
If locate can find other files in the same directory, then the cause must be different.
So it seems that my home dir is effectively invisible to the locate command because the dir is encrypted, this dramatically reduces the utility of the locate command, I wonder if find and grep suffer the same fate ?
A decrypted view of your home directory must be mounted somewhere while you work with it. You have to trigger updatedb to read that location, not the encrypted /home/.ecryptfs. I bet it is mounted as tmpfs filesystem, or as "fuse.<something>". Something which is ignored by updatedb because of PRUNEFS setting.
So it seems that my home dir is effectively invisible to the locate command because the dir is encrypted, this dramatically reduces the utility of the locate command, I wonder if find and grep suffer the same fate ?
Thanks,
Oisín.
You can always remove /home/.ecryptfs from PRUNEPATHS in updatedb.conf, save it, then updatedb and try locate a file in your home directory
find and grep don't use /etc/updatedb.conf
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.