Sign up ×

I am wondering is there a way to increase find speed in terminal, it doesn't make sense that using internet google to search will have a better speed than doing a local search for strings or just file names.

I am wondering is there a way to have a local indexing base, once built, in the future, the find command could be super fast.

Or any other suggestions?


share|improve this question
Can you edit your post with your operating system and/or distribution? –  JodieC Jun 13 '12 at 3:05

4 Answers 4

Try using locate, it should do what you want.

share|improve this answer
Its usually a good idea to flesh out the answer a bit more. Like mentioning what package locate comes from (usually slocate), and to use updatedb for rebuilding the DB. :-) –  Patrick Jun 13 '12 at 0:43

It depends much on what your search criterion is.

If you search for filenames or filename patterns, locate is much faster, but not suitable for freshly generated files, since the index used is normally updated only once per day. But if you can use it, it is super fast.

But with find you can search for file size, file age and other things, which aren't searchable by locate.

If you know where to search, you can use the path to delimit the search scope:

find /some/path -size -10M -size +2M -mtime -365 ...

would only search files from 2 to 10 M, maximum 1 year old in /some/path.

Programs, available in the path can be searched by which, help, lib and configuration files with whereis. Examples:

which java

whereis firefox 
firefox: /usr/bin/firefox /etc/firefox /usr/lib/firefox /usr/share/firefox /usr/share/man/man1/firefox.1.gz
share|improve this answer

Use locate

The reason is that locate uses a database of all the existing directories and files that's already been built just like you imagined!

At some set (and changeable) interval, a job runs does scans the file system and then builds a database with it. It is then this database (locatedb), with its appropriate indexes that the locate command goes against instead of scanning through your hard drive at that point.

So the upside is that it's very fast in comparison to a hard drive scan. The downside is that the locate database (locatedb) is not 'live' so can only be used for files that existed 'as of' the last scan.

To update locatedb now run updatedb (or sudo updatedb if necessary)

btw I just ran sudo updatedb locally and it took 3 1/2 seconds! I have 31,000 files.

share|improve this answer

As others have pointed out, locate may be a better tool for simpler searcher.

However, for more complex searches you're probably stuck with find.

One way to speed up find is to narrow down which directory your files are in instead of searching all of the root directory.

share|improve this answer

Your Answer


