4

I would like to index my entire disk for quick search. I tried Tracker, but it doesn't let me add "/" as a recursively indexed directory. How can I do this?

1

2 Answers 2

8

updatedb / locate is certainly a good choice, if you're looking to index file names. See/upvote cYrus's answer.

However, another option is to simply use find to list the names of all files on your hard drive, and put them in a file:

sudo find / > files.list

Later on, you can look for files with grep:

grep 'myfavoritesong' files.list

Although this looks pretty lame, it actually tends to be fast in practice, even when you have a lot of files.

Of course, that hardly does anything better than locate. However, it is a quick and easy way to index external hard drives.

Taking it further, you may want to hash all the files on your hard drive:

sudo find / -type f -exec sha256sum {} \; > files.sha256

This will probably take a long time.

What it does for you is it gives you a way to locate identical files. Say you find a huge .iso file on your computer:

$ sha256sum huge.iso
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824  huge.iso

You have a feeling that the same file exists somewhere else on your hard drive, and you want to delete one of them to save space. You can grep through the list of hashes to find it:

$ grep 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 files.sha256
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824  huge.iso
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824  archive/path/to/other/huge.iso
1
  • +1: It's an interesting solution. A little bit tricky and maybe not so fast, but surely "didactical"; IMO useful.
    – cYrus
    Jan 11, 2011 at 22:04
3

It should already be indexed regularly with scheduled executions of updatedb that's used by locate. For more info refer to the man of these two programs.

Note: I'm talking about file names only.

You must log in to answer this question.

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