Tuesday, December 13, 2016

Printing VII

Using Command-Line Tools to Manage CUPS


In addition to the CUPS web-based administration utility, you can also
use a variety of command- line tools to configure CUPS. To view CUPS
printer information, you can use the lpstat utility. One of the most
useful options you can use with



lpstat is –t



This will cause lpstat to display all information about all CUPS
printers on the system, as this next example shows:




openSUSE:~ # lpstat –t

scheduler running

no system default destination

device for HPLJ2: parallel:/dev/lp0

HPLJ2 accepting requests since Fri 13 May 2011 10:57:13 AM MDT

printer HPLJ2 is idle.  enabled since Fri 13 May 2011 10:57:13 AM MDT

       Printer is now online.





This shows the default CUPS printer (HPLJ2), how it’s connected
(/dev/lp0), the print job currently being processed (if any), and a
list of pending print jobs.



To cancel a pending print job, you can use the cancel command. The syntax is



cancel job_ID



For example, suppose I sent a huge print job (a Linux user manual from
/usr/share/doc/manual/) and it was assigned a print ID of HPLJ2-4.
While printing, I decided that this was a real waste of paper. I could
kill the job and remove it from the print queue by entering



cancel HPLJ2-4 



at the shell prompt.



This can also be done from within the CUPS web-based administration
utility. Just go to the Jobs tab and select Show Active Jobs. Locate
the job that needs to be canceled and select Cancel Job, as shown in
Figure 16-10.



If you have more than one CUPS printer connected, you can use the




lpoptions –d printer




command to specify the default printer. For example, to set the HPLJ5
printer as the default, I would enter




lpoptions –d HPLJ5



This sets the default printer for all users on the system. Indi-
vidual users can override this setting, however, by creating a file
named


.lpoptions


 in their home directory and adding the following  directive:



default printer_name



If you want to view your printer’s configuration settings, you can enter



lpoptions –l



at the shell prompt.



In addition to the lpoptions command, you can also use the



cupsaccept printer_name



or


cupsreject printer_name



command to enable or disable a printer’s print queue. For example, I could enter



cupsreject HPLJ2



at the shell prompt to disable the printer’s print queue, as shown in
this example:



openSUSE:~ # cupsreject HPLJ2

openSUSE:~ # lpstat is –t

scheduler is running

system default destination: HPLJ2

device for HPLJ2: parallel:/dev/lp0

HPLJ2 not accepting requests since Fri 13 May 2011 11:03:07 AM MDT -

       Rejecting Jobs

printer HPLJ2 is idle.  enabled since Fri 13 May 2011 11:03:07 AM MDT

       Rejecting Jobs



The printer itself will continue processing queued print jobs, but
cupsd will not allow any new jobs to enter the queue. 


The cupsdisable command also includes the --hold option, which stops printing after
the current job is complete. To enable the queue again, I would enter



cupsaccept HPLJ2



at the shell prompt.


To disable the printer itself, not the queue, I could enter



cupsdisable HPLJ2



at the shell prompt, as this example shows:



openSUSE:~ # cupsdisable HPLJ2

openSUSE:~ # lpstat is –t

scheduler is running

system default destination: HPLJ2

device for HPLJ2: parallel:/dev/lp0

HPLJ2 accepting requests since Fri 13 May 2011 11:15:28 AM MDT

printer HPLJ2 disabled since Fri 13 May 2011 11:15:28 AM MDT -

Paused




The print queue will continue to accept jobs, but none of them will be
printed until I enter



cupsenable HPLJ2



at the shell prompt.

The cupsenable command also includes the --release option to release pending jobs for printing.





LX0-104 Exam Objectives (Q)

No comments:

Post a Comment