7

I have written:

locate Origin90SR2DVD.iso

And I received the path where that file is located:

/home/david/Origin90SR2DVD.iso

Then I have written:

cd /home/david

I have run:

ls -lrth

And I cannot find the Origin90SR2DVD.iso file.

Why the file is not in that path?

4
  • 1
    What is the output of locate Origin90SR2DVD.iso?
    – mkasberg
    May 8, 2015 at 19:18
  • @mkasberg /home/david/Origin90SR2DVD.iso
    – Dave
    May 8, 2015 at 19:20
  • @EliahKagan Just edited the question adding postimage.org images
    – Dave
    May 8, 2015 at 19:28
  • @Eliah Kagan Just edited the question adding postimage.org images
    – Dave
    May 8, 2015 at 19:31

2 Answers 2

8

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 by sudo updatedb and then run the same locate 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.

8
  • I runned sudo updatedb , and then I wrote locate Origin90SR2DVD.iso. The output was: /home/david/Pictures/Origin90SR2DVD.iso. So, before running sudo updatedb, the path was /home/david/. Why the locate database was not up to date? Does it need to be updated due to the fact that locate is not a Live technique ? Thank you very very much!
    – Dave
    May 8, 2015 at 19:58
  • @EliahKagan The 2>/dev/null for ~ is for ~/.gvfs..and yeah weird places could be ignored..i will make an edit..
    – heemayl
    May 8, 2015 at 20:06
  • @Dave Check my edits..
    – heemayl
    May 8, 2015 at 20:54
  • @EliahKagan: Seconded and edited :)
    – heemayl
    May 8, 2015 at 21:37
  • @heemayl I should mention, one disadvantage of -print -o -name .gvfs -prune is that if other, non-special files or directories called .gvfs have been created, they'll be pruned as well. If you're searching in just one user's home directory, you may want to append -print -o -path ~/.gvfs -prune instead, which also seems to work well. The only disadvantage is that you must give .gvfs's path exactly as it appears relative to the directory you passed as the first argument to find, e.g., find ~ -name foo -print -o -path ~/.gvfs -prune, find . -name foo -print -o -path ./.gvfs -prune. May 8, 2015 at 22:20
3

Run sudo updatedb to make sure your mlocate database is up to date.

0

Not the answer you're looking for? Browse other questions tagged .