Home / Software / How to Index and Find Files in Linux

How to Index and Find Files in Linux

Source code
Question: I have a virtual private server (or dedicated server) with lots of files from numerous websites. How can I keep my files indexed and search for them whenever I need them?

Answer: There are two tools that make searching for files in Linux easy: locate and slocate. The only difference between the two is that slocate provides some extra security. This is useful if you have people on your server without full root permissions who will be performing the searches. Any files above their user level will be hidden.

If you try typing “locate filename” where “filename” is the name of an actual file, you should receive a list of all files with that name in it. If you do not, that means that your server is not setup to index the files. For that, you need another program called “updatedb”. This updates the index database with all of your files. Depending on the size of your drive, this can become an intense activity, so it is best to do it at a low usage time.

You can also schedule updatedb to run periodically using a cron job. Many Linux distributions have this enabled by default. If you need it, leave it on. If not, you might consider turning it off to save CPU and memory usage.

Photo Source: SXC

Check Also


Importance of web hosting to business

The world of business is very ruthless and unfair in some cases. It is a …