locate command finds a file's path, but the file does not exist in that path [duplicate]
It is possible that you had the Origin90SR2DVD.iso
file in the location /home/david
when the database file of locate
(/var/lib/mlocate/mlocate.db
) was updated last time by cron
(or by yourself). As locate
just for the file names in the database file (thats why it is fast) while searching, you can consider it's technique not live.
Although locate
is showing the location of the file, it is very possible that the file is not present there (might be removed or moved to somewhere else).
You have two ways to be sure of whats going on:
You can update the
locate
database file bysudo updatedb
and then run the samelocate
command.-
Alternately, you can use
find
to do a live search. To look for the file in your home directory recursively:find ~ -type f -iname 'Origin90SR2DVD.iso' -print -o -path ~/.gvfs -prune
-path ~/.gvfs -prune
(thanks to Eliah Kagan) is used so that we do not descend into~/.gvfs
directory while searching. Otherwise we will get a distracting permission denied message, since the directory is owned by root. You can omit this (and see the message) by removing-print -o -path ~/.gvfs -prune
.You can also look for all possible places in the filesystem hierarchy. Here I have considered few places that can contain the file, it will be unusual if your file is found under any other directory.
sudo find /home /root /opt /usr/local /mnt -type f -iname 'Origin90SR2DVD.iso'
EDIT :
locate
's database is updated by cron
on a daily basis. In my system it is run at 6:25 AM everyday (check your's on /etc/crontab
).
Actually anacron
will run the cron
job to ensure that if the computer is Off at that time, the job will be run after the computer is turned On next time. If anacron
is not available, run-parts
will execute the files (including mlocate
) in /etc/cron.daily
directory only at the mentioned time.
Run sudo updatedb
to make sure your mlocate database is up to date.