Installation guide
Chapter 11. Shell Prompt Basics 107
The locate command works very quickly, as long as the database is up to date. That database is auto-
matically updated on a nightly basis, from cron. Cron is a small program that runs in the background,
performing various tasks, such as updating the locate database, at regularly scheduled intervals.
Tip
Cron is a daemon that executes tasks at regularly scheduled intervals. To read the cron man page,
type man cron at the shell prompt.
Cron periodically updates the slocate database, which is used to catalog file location. Switching
between operating systems and shutting down your machine at the end of the day can interfere with
this automatic database update.
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.
Note
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.
Read the man page on anacron (type man anacron at the command line) for more information.
11.7. Printing From The Command Line
Printing is not an involved process whether you click on a button in a GUI or type commands from
the command line. This section explains how to print, cancel, and view print jobs from the command
line, assuming you have a properly configured printer connected to your system.
The lpr command, followed by a filename, sends that specified file to the print queue. For example,
lpr foo.txt prints the foo.txt file.
To view the jobs waiting in the print queue, type lpq at the command line. Type lpq, and you will
see information similar to this:
active root 389 foo.txt
In this example, 389 is the job number.
You can cancel jobs in the queue by typing lprm followed by the print job number displayed when
you use the lpq command. To cancel this print job, type lprm 389 and press [Enter].
11.8. Clearing and Resetting the Terminal
After even one ls command in a shell prompt, the terminal window you are working in can begin
to look crowded. You can always exit from the terminal window and open a new one, but there is a
quicker and easier way to clear the contents displayed in the terminal.
Try typing the command clear at the shell prompt. The clear command does just what it implies:
it clears the terminal window.