17.2 Locating Files and Directories 257
Quite a few “shortcuts” bash uses, aren’tthere?
Each one of these helps bash customize the environment for you.
Among the most important environment variables is the PATH environment variable – which defines
what is known as the default path.
The PATH environment variable for our account billy might look something like this:
PATH=/usr/local/bin:/usr/X11R6/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/billy/bin
It looks crowded, but the PATH statement is a great signpost, which points to where programs can be
found.
Tip: Remember the reference in the previous chapter to the FHS (Filesystem Hierarchy
Standard)? The PATH statement is set according to that standard, and programs are
installed in directories in accordance with the FHS as well. The end result is that the
PATH statement will enable bash to automatically find nearly any program, assuming it
has been installed in accordance with the FHS.
17.2 Locating Files and Directories
There will be times when we know a file or directory exists but we won’t know where to find it.
Searching for a file or directory can be made much easier with the locate command.
With locate,we’ll see every related file or directory which matches our search criterion. Let’ssay
we want to search for all files related to the finger command.
locate finger
The locate command uses a database to check for files and directories which match the string
finger.
Tip: To learn more about locate,readthelocate man page by typing man locate
at a shell prompt.
It’s a handy command which works very quickly – as long as the database is up to date. That database
is automatically updated on a nightly basis, from cron.What’s cron?It’s a small program that runs
in the background, performing various tasks – such as updating the locate database – at regularly
scheduled intervals.
Comments to this Manuals