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?


  • Can you edit your post with your operating system and/or distribution? – Jodie C Jun 13 '12 at 3:05

Try using locate, it should do what you want.

  • 13
    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
  • 1
    This does not work for partitions with indexing turned off. E.g. NTFS partitions suffer from bad performance if indexing is enabled, thus locate won't work for those "as it should". – ojrask Nov 27 '15 at 6:52

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

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.


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.


for a single search operation; I didn't find any speedup; unless trying to narrow down the search using find options.

However; if you want to do multiple find operations on the same set of files; I got a significant speedup populating a temporary file with all the filenames and using grep. Of course this does not take into account files that are added or deleted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.