-->
Previous Table of Contents Next


Managing the Printer Queue with lpq and lprm

Several commands help you administer the printer queue specifically, instead of relying on the lpc command. Two tasks are commonly required by a system administrator: displaying the current queue and removing print jobs in a queue.

To display the current print queue for any printer, use the lpq command. It has the following syntax:


lpq [-l] [-Pprinter_name] [job_ID …] [username …]

With no arguments at all, lpq displays information about the current printer queues. The lpq command normally displays information about who queued the print job, where it is in the queue, the files being printed, and the total size of the files. The -l option displays more information about each entry in the printer queue. Usually, only one line of information is displayed.

A specific printer can be displayed with the -P option, followed by the printer’s name. If no name is supplied, the default system printer is displayed. If one or more job_IDs or usernames is provided, only information about the job or jobs queued by the user is shown.


Note:  
Because users can’t access the Linux printer spooling directories, they can remove queued print jobs only with the lprm command. If you are a system administrator, you might want to let all system users know how to use this command to keep unwanted print jobs from printing.

The lprm command is used to remove files from a printer queue. This command is often mistyped as lpr, which doesn’t remove the file from the queue. To use lprm, you must know the print job ID; or, if you are logged in as root, you can remove all jobs for a particular printer. The syntax of the lprm command is as follows:


lprm [-Pprinter_name] [-] [job_ID …] [username …]

If the single-hyphen argument is used, lprm removes all jobs owned by the user who issues the command. If you are logged in as root, all print jobs are removed. A particular printer’s jobs can be removed by using the -P option. For example, the command


lprm -Phplj -

removes all print jobs queued on the printer hplj by the user who issues the command or all print jobs for that printer, if issued by root.


Warning:  
It is easy to accidentally remove all print jobs for a printer when you use the lprm command as root. Take care to use the proper syntax, or you may get frustrated at having to requeue all the jobs!

If a print job ID or a username is supplied as an argument, lprm removes that job or all jobs submitted by the user. If no arguments are supplied at all, the currently active job submitted by the user is deleted.

When lprm removes files from the queue, it echoes a message to the display. If there are no files to remove, nothing is echoed (and you will be left wondering what, if anything, happened).

If you try to use lprm on a job that is currently being printed, it might not be terminated properly because the file might already reside in the printer’s buffer. In some cases, terminating a job that is currently printing can cause the printer to lock because some output format files can’t handle the termination instructions and freeze when the lock file in the spool directory changes. In cases such as this, the ps command must be used to find the output filter process ID, and then it must be killed.


Note:  
In cases of printer lockup that don’t seem to resolve themselves with the lpc utility, try killing the lpd daemon and restarting it. If that doesn’t work, you will probably have to reboot the entire system.

Terminals

Most Linux systems use only the system console that came with the PC (the PC’s screen and keyboard act as the system console). You won’t have to make any configuration changes to Linux to use the system console effectively.

Some system administrators want to add remote terminals to allow other users to work with Linux simultaneously (it is a multiuser system, after all). New terminals can be added to the system in one of two ways: through a serial port on the back of the PC or through a multiport card with many serial ports on it.

Using Multiport Cards

Multiport cards provide an easy and effective method of adding many serial ports to your system. Multiport cards are offered by dozens of vendors in different configurations. They provide from 2 to 32 additional serial ports per card (for terminals, modems, or printers), and can use several different types of connectors (such as DB25 25-pin connectors, DB9 9-pin connectors, or RJ11 wide telephone-style jacks).

If you are going to use a multiport card, make sure you can find one with software device drivers that are designed to work with Linux. You can’t use any multiport card designed for other versions of UNIX (or Xenix) without modification. Because multiport card device drivers are complex binaries, modification is beyond the scope of most people’s programming abilities.

Multiport cards come with complete instructions for installing the device drivers for the multiport card, as well as configuring the terminals. Because the details of the configurations change depending on the manufacturer of the multiport card, you should consult the documentation accompanying the card for more information.


Previous Table of Contents Next