Finding Linux files with "locate"

posted: Monday 12 April 2010 by Tavis J. Hampton in: VPS & Dedicated Software

Kid with magnifying glass

There are a few of ways to find files on a Linux server, but most of them involve actually searching through each file in the filesystem until the correct one is located. This can be time consuming and taxing on the server’s CPU load, especially if you have a lot of files.

Linux has two commands that make searching a little easier: locate and slocate. Unlike other find utilities, locate searches through a database that contains information about the filesystem, bringing up the search results almost instantaneously. The command to update the database is called “updatedb”, and many Linux distributions have the command run via cron every day.

The alternative version of locate, called slocate, is a security-enhanced version that only allows the user to find files he or she has the permission to access. While locate is a great tool for finding things on a server, it does have its issues. For one, you will only find files that were added or changed prior to the last updatedb execution. Furthermore, the very process of updating the database can be taxing on the server, even if it is only once a day. For the right situations, however, locate is a very useful Linux tool.

Photo Source: Flickr

1 stelle2 stelle3 stelle4 stelle5 stelle (no votes)
share this 0 comments

Be the first to add a comment to this article.

Your email address is required but won't be displayed.
Leave a comment

Register to reserve your nickname accross all the blogs in the Blogo network and to upload your avatar. If you already are registered, login to user your nickname.

Yes No

Comment preview

Network Blogo