[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how to locate files on my computer



tom wrote:
> I thought using the command: $ locate <named files>  would work, but
> nothing happens, even if I su to root.  Any help appreciated.

The locate command operates on a pre-compiled database.  The database
is updated nightly in the /etc/cron.daily/locate script.  If you have
created or renamed a file today and then 'locate' it today the locate
using yesterday's database won't yet know about it.  But for files
that it does know about it is very, very fast at finding that file.

As Neal posted 'find' will find files that exist at this moment on the
filesystem.  This might take a while but will eventually walk all of
the directories and find the files.  In addition to Neal's suggestion
I would add -xdev to avoid walking through /proc, /sys, and /dev.

  find -xdev / -name 'somefilename'

If you think it is in your home directory then just look there instead
of across the entire machine.

  find ~/ -name 'somefilename'

Or just for a piece of the name and use file glob wild cards for the
rest of the name.

  find ~/ -name '*some piece of a name*'
  find ~/ -name '*pie*'

Bob

Attachment: signature.asc
Description: Digital signature


Reply to: