6.4. Command-Line Tools for LPRng

This section only provides a short overview of the available tools. For details, consult the LPRng Howto, in particular, section /usr/share/doc/packages/lprng/LPRng-HOWTO.html#LPRNGCLIENTS.

6.4.1. Managing Local Queues Printing Files

Details on how to use the lpr command can be found in the LPRng Howto (/usr/share/doc/packages/lprng/LPRng-HOWTO.html#LPR). The following only covers some basic operations.

To print a file, you normally must enter lpr -Pqueuename filename. If you leave out the -Pqueuename parameter, the printing system defaults to the value of the environment variable PRINTER. The same is true for the commands lpq and lprm. See the manual pages of lpr, lpq, and lprm for more information. The environment variable PRINTER is set automatically on login. Display its current value with echo $PRINTER. Change it to expand to another queue by entering export PRINTER=queuename. Checking the Status

By entering lpq -Pqueuename, check the status of print jobs handled by the specified queue. If you specify all as the queue name, lpq displays information for all jobs in all queues.

With lpq -s -Pqueuename, tell lpq to display only a minimum of information. lpq -l -Pqueuename tells lpq to be more verbose.

With lpq -L -Pqueuename, lpq displays a detailed status report, which will come in handy when trying to track down errors.

For further information, see the manual page of lpq, and section /usr/share/doc/packages/lprng/LPRng-HOWTO.html#LPQ of the LPRng Howto. Removing Jobs from the Queue

The command lprm -Pqueuename jobnumberremoves the print job with the specified number from the specified queue, if you own the job. A print job is owned by the user who started it. Display the owner and the job number of print jobs with lpq.

The command lprm -Pall all removes all print jobs from all queues for which you have the required permissions. root may remove any jobs in any queues regardless of permissions.

More information can be obtained in the manual page of lprm and in the LPRng Howto (/usr/share/doc/packages/lprng/LPRng-HOWTO.html#LPRM). Controlling the Queues

The command lpc option queuename displays the status of the specified queue and allows changing it. The most important options are:


Display a short overview of the available options.

status queuename

Display status information.

disable queuename

Do not accept new jobs for the specified queue.

enable queuename

Accept new jobs for the specified queue.

stop queuename

Stop printing from the specified queue. If a job is being printed, it will be completed.

start queuename

Enable printing from the specified queue.

down queuename

Has the effect of disable and stop combined.

up queuename

Has the effect of enable and start combined.

abort queuename

Has the effect of down, but aborts all current print jobs immediately. Aborted jobs are preserved, however, and can be resumed after restarting the queue with up.

root permissions are required to control printer queues with the above commands. Options can be supplied to lpc directly on the command line (as in lpc status all). You can also run the program without any options, which starts it in dialog mode — it opens the lpc> command prompt. Then enter the options at the prompt. To leave the program, enter either quit or exit.

If you were to enter lpc status all, the output could look like this:

Printer        Printing Spooling Jobs Server Subserver
lp@earth        enabled  enabled    2    123       456
color@earth    disabled disabled    0   none      none
laser@earth    disabled  enabled    8   none      none

This gives the following information: Queue lp is completely enabled and holds two print jobs, one of which is being printed at the moment. Queue color, on the other hand, is completely stopped. Finally, the laser queue does not print at the moment, but jobs (there are currently eight of them) are still accepted for the queue and are accumulating in the spooler.

Further information can be obtained from the manual page of lpc and the LPRng Howto (/usr/share/doc/packages/lprng/LPRng-HOWTO.html#LPC).

6.4.2. Managing Remote Queues

For each of the commands explained below, replace <printserver> with the name or IP address of your print server. <queuename> must be a queue on the print server. Printing Files

With the LPRng spooler, even remote queues can be addressed directly, using the lpr command with the syntax lpr -Pqueuename@printserver file. This is only possible if the print server is configured to accept remote print jobs on its queues. This is enabled by default with LPRng. Checking the Status

Check the status of a queue on a remote host by entering:

lpq -P<queuename>@<printserver>
lpq -s -P<queuename>@<printserver>
lpq -l -P<queuename>@<printserver>
lpq -L -P<queuename>@<printserver>


lpc status <queuename>@<printserver>
lpc status all@<printserver>

To list the names of and display status information on all queues of a print server, use either lpq -s -Pall@printserver or lpc status all@printserver, provided that LPRng is used on the print server.

If printing over a remote queue does not work, querying the status of the queues helps determine the cause of the problem. If LPRng is installed on the print server, enter lpq -L -Pqueuename@printserver to get a detailed status report for remote diagnosis. Removing Jobs from the Queue

With the following command delete all print jobs in remote queues that have been issued under your user name:

lprm -P<queuename>@<printserver> <jobnumber>
lprm -P<queuename>@<printserver> all
lprm -Pall@<printserver> all

root has no special privileges on remote queues. The parameter all only works if LPRng is used on the print server host as well.

6.4.3. Command-Line Tools for LPRng Troubleshooting

Print jobs are kept in the queue even if you shut down a machine during a printout so are still there after rebooting. To remove a faulty print job, use the commands described above. Rebooting will not remove them.

For example, it sometimes happens that the host-to-printer connection suffers some kind of fault, after which the printer is unable to interpret data correctly. This can cause it to spit out large amounts of paper with meaningless characters on it.

  1. In the case of an inkjet model, remove all paper from the trays. Open the paper tray if you have a laser model.

  2. In most cases, the print job is still in the queue after that. Print jobs are removed from the queue only after all data has been sent to the printer. Check with lpq or lpc status to see which queue is printing then delete the job in question with lprm.

  3. The printer may produce some output even after deleting the job from the queue. To stop this, use the commands fuser -k /dev/lp0 for a printer on the first parallel port or fuser -k /dev/usb/lp0 for the first USB printer to terminate all processes still using the printer device.

  4. Do a complete reset of the printer by switching it off. Wait a few seconds before putting the paper back into the trays and switching the device back on.