Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions

  




 

 

13.6. Locating Files and Directories

There will be times when you know a file or directory exists but you will not know where to find it. Search for a file or directory with the locate command.

With locate, you will see every file or directory whose name contains the search criterion. For example, if you want to search for all files with the word finger in the name, type:

locate finger

The locate command uses a database to locate files and directories that have the word finger in the file or directory name. The search results could include a file called finger.txt, a file called pointerfinger.txt, a directory named fingerthumbnails, and so on. To learn more about locate, read the locate man page (type man locate at a shell prompt).

The locate command works very quickly, as long as the database is up to date. That database is automatically updated on a nightly basis through a cron job. cron is a small program that runs in the background, performing various tasks (such as updating the locate database) at regularly scheduled intervals.

TipTip
 

Cron is a daemon that executes tasks at regularly scheduled intervals. To read the cron man page, type man cron at the shell prompt. Refer to the Red Hat Linux Customization Guide for more information on cron.

The cron task periodically updates the slocate database, which is used to catalog file locations. Switching between operating systems and shutting down your machine at the end of the day can interfere with the automatic database update run by cron.

To update the database manually, log in as root (type su at a shell prompt and then your root password) and type the command updatedb.

After a few minutes, the slocate database that is used by the locate command will be current.

NoteNote
 

You can run anacron to have your system execute commands periodically, with a frequency specified in days. Unlike cron, it does not assume that the machine is running continuously. Hence, it can be used on machines that are not running 24 hours a day, to control daily, weekly, and monthly jobs that are usually controlled by cron.

Refer to the man page on anacron (type man anacron at the command line) and the Red Hat Linux Customization Guide for more information.

 
 
  Published under the terms of the GNU General Public License Design by Interspire