Results 1 to 7 of 7

Thread: Created file - but cannot find with locate command?

  1. #1
    Join Date
    Jun 2010
    Beans
    16

    Created file - but cannot find with locate command?

    I have created a file on the ubuntu desktop. However, at the command line, if I enter the following....


    locate testfile.txt OR

    locate testfile


    it doesn't provide the expected result (i.e. the location of the file) whereas if I try this with another file, it shows the file location.


    Can anyone shed any light on this?

  2. #2
    Join Date
    Sep 2011
    Beans
    71
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Created file - but cannot find with locate command?

    You need to run the command updatedb as root before you can find a recently created file using locate
    Last edited by ubiquitin.jf; September 18th, 2011 at 12:54 PM.

  3. #3
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: Created file - but cannot find with locate command?

    locate uses a database to read the filenames. The database is updated daily by a cron job. As ubiquitin.jf pointed it out, you can manually update the database with sudo updatedb.

  4. #4
    Join Date
    Jun 2010
    Beans
    16

    Re: Created file - but cannot find with locate command?

    @ubiquitin.jf & sisco311: Thanks for your replies. I carried out a manual update as suggested. However, I still can't pull up this file. Is there any other reason why this would happen?

  5. #5
    Join Date
    Apr 2010
    Location
    England
    Beans
    3,286

    Re: Created file - but cannot find with locate command?

    Quote Originally Posted by borderfox View Post
    @ubiquitin.jf & sisco311: Thanks for your replies. I carried out a manual update as suggested. However, I still can't pull up this file. Is there any other reason why this would happen?
    Yes. By default, updatedb only scans and indexes files on the root partition. Any filesystems mounted in /mount, as well as any files stored in /proc, /dev, /sys, /tmp or /var/spool, will not be scanned and subsequently won't be added to the database.
    http://xkcd.com/293/
    There are 10 kinds of people in this world: Those who understand ternary, those who don't, and those who confuse it with binary.

  6. #6
    Join Date
    Jun 2010
    Beans
    16

    Re: Created file - but cannot find with locate command?

    Quote Originally Posted by WorMzy View Post
    Yes. By default, updatedb only scans and indexes files on the root partition. Any filesystems mounted in /mount, as well as any files stored in /proc, /dev, /sys, /tmp or /var/spool, will not be scanned and subsequently won't be added to the database.
    Excelllent - thanks for your help.

  7. #7
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: Created file - but cannot find with locate command?

    You could use find to search for files. http://mywiki.wooledge.org/UsingFind

    Or create a local database:
    Code:
    updatedb -l 0 -o ./my-db -U /path/to/dir
    locate -d ./my-db PATTERN

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •