7

How do I re-scan my drive so my 'search utilities' are able to find a new file on my system?

I'm having a tough time googling HOW TOs for launching an index/scan command to any of this applications. I mostly use: 'find' and 'locate', but thought it would be a good idea to know about other search apps and their index/scan commands (Sorry, don't know what to best call it: index or scan for scanning new files on the system).

  • My problem: I install or download a new file to the system but don't know where.
  • My Need: To scan my drive (preferably by folder, but i'm willing to live with a full scan)
  • My OS: Linux Debian (Lenny)

Thank you!

weegee
  • 143
  • 7
l0c0b0x
  • 11,697
  • 6
  • 46
  • 76

4 Answers4

12

Find does not need an index, and traverses the disk every time you run it. Example

$ find / -name "*mynewprogram*"

locate and variants need index files, but they work -really- faster. 'locate' is from GNU findutils. 'slocate' was recommended up to etch; it was a more 'secure' version of locate, users will not see files that they do not have acess to. 'mlocate' is recommended in lenny and newer, mlocate has a more efficient indexing mechanism.

$ sudo updatedb  # to update the index.
$ mlocate  mynewprogram

which searches your $PATH for the binary name you give. No need for an index.

$ which touch
/usr/bin/touch

If you want to see a package's installed files, use this

dpkg -L coreutils

To see which package installed a specific file

$ dpkg -S /usr/bin/touch
coreutils: /usr/bin/touch
hayalci
  • 3,611
  • 3
  • 25
  • 37
  • Thanks, your recommendations worked. I didn't know about mlocate, and it wasn't there on the default Lenny install... neither was locate, but apt-getted 'locate' and didn't know how to update/index the db. What's the difference between mlocate and locate? (they both seem pretty similar) – l0c0b0x May 22 '09 at 15:20
  • updated the answer – hayalci May 23 '09 at 23:23
  • Worth noting is that `find` does appear to cache the result, if you run the command a second time it is much faster, so it may appear to be 'indexed' in a sense but it is just cached. And it appears to almost cache the path/index it because if you change the filename but keep same path it is just as fast as the cached lookup. – Elijah Lynn Aug 01 '17 at 18:47
  • find would only benefit from Linux directory entry cache, as you have observed. It's a built-in Linux feature, not a speedup that find implements to replace an index. – hayalci Dec 26 '17 at 20:38
2

try

updatedb -v

[ -v to be sure it actually works ;-]

i also use sometimes

cd /whatever/is/the/path
find .|grep -i somePatternMatchingWhatIneed
pQd
  • 29,561
  • 5
  • 64
  • 106
2

Use the find command.

Here are some examples and syntax documents. Unfortunately I can't add hyperlinks yet :(.

http://linux.about.com/od/commands/a/blcmdl1_findx.htm

http://linux.about.com/od/commands/l/blcmdl1_find.htm

Elijah Lynn
  • 139
  • 3
  • 16
  • You can link to sources to support your explanation but you still need to explain your answer here on S.O. Think of it as, "Will my answer still make sense when those links are broken/removed?". – Elijah Lynn Aug 01 '17 at 18:42
2

If you want to search inside the contents of a file, not just on the filename, then you need a dedicated daemon that will index everyfile as it's created/modified and provide a fast search to that index.

You might want to try:

Amandasaurus
  • 30,211
  • 62
  • 184
  • 246