How to Locate a File

There are several ways to locate a file. The most commonly used one in the computer industry is known as grep. Grep can locate files with text within them, but can produce immense amounts of spam when the keyword it is told to search for is a common combination of letters.

To locate something by file name, use the locate comand instead. The locate command searches a database of information that contains the names and locations of all the files it knows about. Thus, it is much faster than the grep command, which searches the computer itself.

However, to make certain that the locate command actually knows what files are on the computer, each time a new program is installed, running the program that updates the database is a good idea. Su to root and type

and the computer will think for a few moments as it searches all the files for their locations and stores those locations in its database.

Then, whenever it becomes necessary to locate a file, simply type

locate filename
where filename is a portion of the filename that should be located. Locate will print out a list of all of the places it located that combination of letters in a filename.
Back to the Table of Contents.
Created: May 12, 1999
Last updated: May 13, 1999