Ceci est une ancienne révision du document !


Printer Management

Introduction

The Common Unix Printing System is a printer management system for Unix and Unix-like operating systems owned by Apple™ who purchased the source code when they hired the main developer, Michael Sweet of Easy Software Products.

Protocols

Cups uses a protocol called IPP on ports udp/631 and tcp/631.

IPP :

  • is an extension of the HTTP protocol,
  • allows administration of CUPS via a web browser,
  • allows the use of URLs to define print spoolers.

Cups is also compatible with:

  • tcp/515 for BSD based systems,
  • tcp/9100 for HP networked JeTDirect printers.

Daemon

cupsd is the CUPS system daemon. When CUPS handles a print job, it first passes it to a filter appropriate for the model of the printer to be used and then to a backend dependant upon the type off connection being used. Communication between CUPS, filters and backends is accomplished through spools and pipes.

Configuration

/etc/cups/cupsd.conf

The main configuration file for CUPS is /etc/cups/cupsd.conf. In that file can be found:

  • the port that IPP is listening on,
  • the user account and group used by the CUPS server,
  • the log level,
  • the Browse server configuration used to discover printers on the network,
  • the spool Acces Control Lists,
  • the administration area Access Control Lists.
[root@centos ~]# cat /etc/cups/cupsd.conf
MaxLogSize 0
#
# "$Id: cupsd.conf.in 8805 2009-08-31 16:34:06Z mike $"
#
# Sample configuration file for the CUPS scheduler.  See "man cupsd.conf" for a
# complete description of this file.
#

# Log general information in error_log - change "warn" to "debug"
# for troubleshooting...
LogLevel warn

# Administrator user group...
SystemGroup sys root


# Only listen for connections from the local machine.
Listen localhost:631
Listen /var/run/cups/cups.sock

# Show shared printers on the local network.
Browsing On
BrowseOrder allow,deny
BrowseAllow all
BrowseLocalProtocols CUPS dnssd

# Default authentication type, when authentication is required...
DefaultAuthType Basic

# Restrict access to the server...
<Location />
  Order allow,deny
</Location>

# Restrict access to the admin pages...
<Location /admin>
  Order allow,deny
</Location>

# Restrict access to configuration files...
<Location /admin/conf>
  AuthType Default
  Require user @SYSTEM
  Order allow,deny
</Location>

# Set the default printer/job policies...
<Policy default>
  # Job-related operations must be done by the owner or an administrator...
  <Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job CUPS-Move-Job CUPS-Get-Document>
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>

  # All administration operations require an administrator to authenticate...
  <Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS-Delete-Class CUPS-Set-Default CUPS-Get-Devices>
    AuthType Default
    Require user @SYSTEM
    Order deny,allow
  </Limit>

  # All printer operations require a printer operator to authenticate...
  <Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Restart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After CUPS-Accept-Jobs CUPS-Reject-Jobs>
    AuthType Default
    Require user @SYSTEM
    Order deny,allow
  </Limit>

  # Only the owner or an administrator can cancel or authenticate a job...
  <Limit Cancel-Job CUPS-Authenticate-Job>
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>

  <Limit All>
    Order deny,allow
  </Limit>
</Policy>

# Set the authenticated printer/job policies...
<Policy authenticated>
  # Job-related operations must be done by the owner or an administrator...
  <Limit Create-Job Print-Job Print-URI>
    AuthType Default
    Order deny,allow
  </Limit>

  <Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job CUPS-Move-Job CUPS-Get-Document>
    AuthType Default
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>

  # All administration operations require an administrator to authenticate...
  <Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS-Delete-Class CUPS-Set-Default>
    AuthType Default
    Require user @SYSTEM
    Order deny,allow
  </Limit>

  # All printer operations require a printer operator to authenticate...
  <Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Restart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After CUPS-Accept-Jobs CUPS-Reject-Jobs>
    AuthType Default
    Require user @SYSTEM
    Order deny,allow
  </Limit>

  # Only the owner or an administrator can cancel or authenticate a job...
  <Limit Cancel-Job CUPS-Authenticate-Job>
    AuthType Default
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>

  <Limit All>
    Order deny,allow
  </Limit>
</Policy>

#
# End of "$Id: cupsd.conf.in 8805 2009-08-31 16:34:06Z mike $".
#

Filters

Available filters for the version of CUPS being used can be found in the /usr/lib/cups/filter directory:

[root@centos ~]# ls /usr/lib/cups/filter
bannertops      commandtoescpx  foomatic-rip  hpcups     hplipjs        pdftops      pstops      rastertodymo   rastertogutenprint.5.2  rastertopclx  texttopaps
commandtocanon  commandtopclx   gziptoany     hpcupsfax  imagetops      pdftoraster  pstopxl     rastertoepson  rastertohp              rastertoptch  texttops
commandtoepson  commandtops     hpcac         hpgltops   imagetoraster  pstopdf      pstoraster  rastertoescpx  rastertolabel           textonly

Backends

Available backends for the version of CUPS being used can be found in the /usr/lib/cups/backend directory

[root@centos ~]# ls /usr/lib/cups/backend
beh  dnssd  http  https  ipp  lpd  mdns  ncp  parallel  scsi  serial  smb  snmp  socket  usb

Active backends for the server on which CUPS is being used can be found by using the following command:

[root@centos ~]# lpinfo -v
network https
network lpd
network ipp
network http
network socket
direct scsi
network smb
network beh

Logs

CUPS logs are stored in /var/log/cups:

[root@centos ~]# ls -l /var/log/cups
total 24
-rw-------. 1 root lp 9522 Dec  7 15:09 access_log
-rw-------. 1 root lp 8879 Dec  7 15:09 error_log

Printers

Available printers for the version of CUPS being used can be found by using the following command:

[root@centos ~]# lpinfo -m | more
foomatic:Alps-MD-1000-md2k.ppd Alps MD-1000 Foomatic/md2k
foomatic:Alps-MD-1000-ppmtomd.ppd Alps MD-1000 Foomatic/ppmtomd
foomatic:Alps-MD-1300-md1xMono.ppd Alps MD-1300 Foomatic/md1xMono
foomatic:Alps-MD-1300-md2k.ppd Alps MD-1300 Foomatic/md2k
foomatic:Alps-MD-1300-ppmtomd.ppd Alps MD-1300 Foomatic/ppmtomd
foomatic:Alps-MD-1500-md1xMono.ppd Alps MD-1500 Foomatic/md1xMono
foomatic:Alps-MD-1500-md2k.ppd Alps MD-1500 Foomatic/md2k
foomatic:Alps-MD-1500-ppmtomd.ppd Alps MD-1500 Foomatic/ppmtomd
foomatic:Alps-MD-2000-md2k.ppd Alps MD-2000 Foomatic/md2k
foomatic:Alps-MD-2000-ppmtomd.ppd Alps MD-2000 Foomatic/ppmtomd
foomatic:Alps-MD-2010-ppmtomd.ppd Alps MD-2010 Foomatic/ppmtomd
foomatic:Alps-MD-2300-ppmtomd.ppd Alps MD-2300 Foomatic/ppmtomd
foomatic:Alps-MD-4000-md2k.ppd Alps MD-4000 Foomatic/md2k
foomatic:Alps-MD-4000-ppmtomd.ppd Alps MD-4000 Foomatic/ppmtomd
foomatic:Alps-MD-5000-md5k.ppd Alps MD-5000 Foomatic/md5k
foomatic:Alps-MD-5000-md50Eco.ppd Alps MD-5000 Foomatic/md50Eco
foomatic:Alps-MD-5000-md50Mono.ppd Alps MD-5000 Foomatic/md50Mono
foomatic:Alps-MD-5000-ppmtomd.ppd Alps MD-5000 Foomatic/ppmtomd
foomatic:Alps-MD-5500-ppmtomd.ppd Alps MD-5500 Foomatic/ppmtomd
foomatic:Anitech-M24-epson.ppd Anitech M24 Foomatic/epson
drv:///hp/hpcups.drv/apollo-2100.ppd Apollo 2100, hpcups 3.12.4
drv:///hp/hpcups.drv/apollo-2150.ppd Apollo 2150, hpcups 3.12.4
drv:///hp/hpcups.drv/apollo-2200.ppd Apollo 2200, hpcups 3.12.4
drv:///hp/hpcups.drv/apollo-2500.ppd Apollo 2500, hpcups 3.12.4
drv:///hp/hpcups.drv/apollo-2600.ppd Apollo 2600, hpcups 3.12.4
drv:///hp/hpcups.drv/apollo-2650.ppd Apollo 2650, hpcups 3.12.4
foomatic:Apollo-P-1200-pcl3.ppd Apollo P-1200 Foomatic/pcl3
foomatic:Apollo-P-1220_Barbie-pcl3.ppd Apollo P-1220 Barbie Foomatic/pcl3
foomatic:Apollo-P-1250-pcl3.ppd Apollo P-1250 Foomatic/pcl3
gutenprint.5.2://pcl-apollo-p2100/expert Apollo P-2100 - CUPS+Gutenprint v5.2.5
gutenprint.5.2://pcl-apollo-p2100/simple Apollo P-2100 - CUPS+Gutenprint v5.2.5 Simplified
foomatic:Apollo-P-2100-hpijs-pcl3.ppd Apollo P-2100 Foomatic/hpijs-pcl3
--More--

Administration

The CUPS server can be administered on the command line by using the following commands:

Command Description
lpadmin The main administration command for adding, deleting and modifying spools
accept Allows jobs to be added to a spool
reject Disallows jobs to be added to a spool
cupsenable Allows jobs in a spool to be processed
cupsdisable Disallows jobs in a spool to be processed
lpstat Lists the queud jobs
cancel Deletes jobs
lpmove Moves jobs from one spool to another
lpinfo Lists the filters, backends and printers
lppasswd Administers accounts specific to CUPS

The lpstat Command

The lpstat command is used too view the list of spools:

[root@centos ~]# lpstat -t
scheduler is running
no system default destination
lpstat: No destinations added.
lpstat: No destinations added.
lpstat: No destinations added.
lpstat: No destinations added.

The lpadmin Command

Create a RAW printer spool as follows:

[root@centos ~]# lpadmin -p pri1 -v socket://localhost:12000 -m raw

The switches used here are as follows:

Switch Description
-p The spool name
-v The printer represented as an URL
-m The model to use or the driver

The URLs can be of the follwoing types:

URL Description
file:/path/filename Print to a file
http://server:631/ipp/port1 Print via HTTP
lpd://server/queue Print via LPD
ipp://server:631/printers/queue Print via IPP
smb://workgroup/serveur/nompartage Print via SMB
socket://server Print via JetDirect
serial:/dev/ttyS0?baud=1200+bits=8+parity=none+flow=none Print via a serial port
parallel:/dev/lp0 Print via a parallel port

Now check that the spool has been created :

[root@centos ~]# lpstat -t
scheduler is running
no system default destination
device for pri1: socket://localhost:12000
pri1 not accepting requests since Sat 07 Dec 2013 03:35:52 PM CET -
	reason unknown
printer pri1 disabled since Sat 07 Dec 2013 03:35:52 PM CET -
	reason unknown

The accept and cupsenable Commands

It is now possible to use the accept and cupsenable commands to activate the print spool:

[root@centos ~]# accept pri1
[root@centos ~]# lpstat -t
scheduler is running
no system default destination
device for pri1: socket://localhost:12000
pri1 accepting requests since Sat 07 Dec 2013 03:35:52 PM CET
printer pri1 disabled since Sat 07 Dec 2013 03:35:52 PM CET -
	reason unknown
[root@centos ~]# cupsenable pri1
[root@centos ~]# lpstat -t
scheduler is running
no system default destination
device for pri1: socket://localhost:12000
pri1 accepting requests since Sat 07 Dec 2013 03:42:45 PM CET
printer pri1 is idle.  enabled since Sat 07 Dec 2013 03:42:45 PM CET

Setting Up the Default Printer

The -d option of the lpadmin command can be used to define a spool as the default destination:

[root@centos ~]# lpadmin -d pri1
[root@centos ~]# lpstat -t
scheduler is running
system default destination: pri1
device for pri1: socket://localhost:12000
pri1 accepting requests since Sat 07 Dec 2013 03:42:45 PM CET
printer pri1 is idle.  enabled since Sat 07 Dec 2013 03:42:45 PM CET

Using a .ppd File to Add a Printer

Now create a spool for an HP Color LaserJet Series PCL 6 using the pxlcolor.ppd file:

[root@centos ~]# lpadmin -p Printer1 -E -v parallel:/dev/print1 -m pxlcolor.ppd
[root@centos ~]# lpstat -t
scheduler is running
system default destination: pri1
device for pri1: socket://localhost:12000
device for Printer1: parallel:/dev/print1
pri1 accepting requests since Sat 07 Dec 2013 03:42:45 PM CET
Printer1 accepting requests since Sat 07 Dec 2013 03:48:38 PM CET
printer pri1 is idle.  enabled since Sat 07 Dec 2013 03:42:45 PM CET
printer Printer1 is idle.  enabled since Sat 07 Dec 2013 03:48:38 PM CET

<note important> Note that the use of the -E switch enables the spool automatically. </note>

Because this printer is not real, we will create a spool manually:

[root@centos ~]# touch /dev/print1 ; chgrp lp /dev/print1 ; chmod 660 /dev/print1

Now test this new printer:

[root@centos ~]# echo "Test Printer File" > /tmp/test.print
[root@centos ~]# lpadmin -d Printer1
[root@centos ~]# lpstat -t
scheduler is running
system default destination: Printer1
device for pri1: socket://localhost:12000
device for Printer1: parallel:/dev/print1
pri1 accepting requests since Sat 07 Dec 2013 03:42:45 PM CET
Printer1 accepting requests since Sat 07 Dec 2013 03:48:38 PM CET
printer pri1 is idle.  enabled since Sat 07 Dec 2013 03:42:45 PM CET
printer Printer1 is idle.  enabled since Sat 07 Dec 2013 03:48:38 PM CET
[root@centos ~]# 
[root@centos ~]# 
[root@centos ~]# lp /tmp/test.print
request id is Printer1-3 (1 file(s))

<note important> Note that the job is called Printer1-3. </note>

Now create a second spool for an HP Color LaserJet Series PCL 6 using the pxlcolor.ppd file:

[root@centos ~]# lpadmin -p Printer2 -E -v parallel:/dev/print2 -m pxlcolor.ppd
[root@centos ~]# lpstat -t
scheduler is running
system default destination: Printer1
device for pri1: socket://localhost:12000
device for Printer1: parallel:/dev/print1
device for Printer2: parallel:/dev/print2
pri1 accepting requests since Sat 07 Dec 2013 03:42:45 PM CET
Printer1 accepting requests since Tue 10 Dec 2013 09:47:24 AM CET
Printer2 accepting requests since Tue 10 Dec 2013 09:49:59 AM CET
printer pri1 is idle.  enabled since Sat 07 Dec 2013 03:42:45 PM CET
printer Printer1 disabled since Tue 10 Dec 2013 09:47:24 AM CET -
	Starting GPL Ghostscript 8.70...
printer Printer2 is idle.  enabled since Tue 10 Dec 2013 09:49:59 AM CET
Printer1-3              root              1024   Tue 10 Dec 2013 09:47:18 AM CET

Classes

A class is a group of identical printers. Jobs sent to a class are printed on the first available member printer.

To create a class, use the lpadmin command as follows:

[root@centos ~]# lpadmin -p Printer1 -c classe1
[root@centos ~]# lpadmin -p Printer2 -c classe1

Check that the class has been created:

[root@centos ~]# lpstat -t
scheduler is running
system default destination: Printer1
members of class classe1:
	Printer1
	Printer2
device for classe1: ///dev/null
device for pri1: socket://localhost:12000
device for Printer1: parallel:/dev/print1
device for Printer2: parallel:/dev/print2
classe1 not accepting requests since Tue 10 Dec 2013 10:08:54 AM CET -
	reason unknown
pri1 accepting requests since Sat 07 Dec 2013 03:42:45 PM CET
Printer1 accepting requests since Tue 10 Dec 2013 09:47:24 AM CET
Printer2 accepting requests since Tue 10 Dec 2013 09:49:59 AM CET
printer classe1 disabled since Tue 10 Dec 2013 10:08:54 AM CET -
	reason unknown
printer pri1 is idle.  enabled since Sat 07 Dec 2013 03:42:45 PM CET
printer Printer1 disabled since Tue 10 Dec 2013 09:47:24 AM CET -
	Starting GPL Ghostscript 8.70...
printer Printer2 is idle.  enabled since Tue 10 Dec 2013 09:49:59 AM CET
Printer1-3              root              1024   Tue 10 Dec 2013 09:47:18 AM CET

<note important> CUPS can also create Implicit Classes automatically. These work just like normal classes but are created automatically as function of what printers and other classes have been configured. Note that classes can also contain other classes. </note>

The /etc/cups/printers.conf File

The configuration of each printer for which a spool has been declared under cups can be found in the /etc/cups/printers.conf file:

[root@centos ~]# cat /etc/cups/printers.conf
# Printer configuration file for CUPS v1.4.2
# Written by cupsd on 2013-12-10 09:50
# DO NOT EDIT THIS FILE WHEN CUPSD IS RUNNING
<Printer pri1>
Info pri1
DeviceURI socket://localhost:12000
State Idle
StateTime 1386427365
Type 4
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
</Printer>
<DefaultPrinter Printer1>
Info Printer1
MakeModel HP Color LaserJet Series PCL 6 CUPS
DeviceURI parallel:/dev/print1
State Stopped
StateMessage Starting GPL Ghostscript 8.70...
StateTime 1386665244
Reason paused
Type 8400972
Filter application/vnd.cups-raw 0 -
Filter application/vnd.cups-postscript 100 pstopxl
Filter application/vnd.cups-pdf 0 pstopxl
Filter application/vnd.cups-command 0 commandtops
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
</Printer>
<Printer Printer2>
Info Printer2
MakeModel HP Color LaserJet Series PCL 6 CUPS
DeviceURI parallel:/dev/print2
State Idle
StateTime 1386665399
Type 8400972
Filter application/vnd.cups-raw 0 -
Filter application/vnd.cups-postscript 100 pstopxl
Filter application/vnd.cups-pdf 0 pstopxl
Filter application/vnd.cups-command 0 commandtops
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
</Printer>

The /etc/cups/classes.conf File

The configuration of each class for which a spool has been declared under cups can be found in the /etc/cups/classes.conf file:

[root@centos ~]# cat /etc/cups/classes.conf
# Class configuration file for CUPS v1.4.2
# Written by cupsd on 2013-12-10 10:09
# DO NOT EDIT THIS FILE WHEN CUPSD IS RUNNING
<Class classe1>
Info classe1
State Stopped
StateTime 1386666534
Accepting No
Shared Yes
JobSheets none none
Printer Printer1
Printer Printer2
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy retry-current-job
</Class>

The cancel Command

The cancel command is used to delete a job:

[root@centos ~]# lpstat
Printer1-3              root              1024   Tue 10 Dec 2013 09:47:18 AM CET
[root@centos ~]# cancel Printer1-3
[root@centos ~]# lpstat
[root@centos ~]# 

The lpmove Command

The lpmove command is used to moce the entire spool content from one spool to another:

Define pri1 as the default printer:

[root@centos ~]# lpadmin -d pri1

Create a new print job:

[root@centos ~]# lp /tmp/test.print
request id is pri1-4 (1 file(s))
[root@centos ~]# lpstat
pri1-4                  root              1024   Tue 10 Dec 2013 10:33:05 AM CET

Moce the contents of the pri1 spool to class1:

[root@centos ~]# lpmove pri1 classe1
[root@centos ~]# lpstat
classe1-4               root              1024   Tue 10 Dec 2013 10:33:05 AM CET

Destroying a Class

The removal of a spool from a class requires the use of the lpadmin:

[root@centos ~]# lpadmin -p Printer1 -r classe1
[root@centos ~]# lpadmin -p Printer2 -r classe1
[root@centos ~]# lpstat -t
scheduler is running
system default destination: pri1
device for pri1: socket://localhost:12000
device for Printer1: parallel:/dev/print1
device for Printer2: parallel:/dev/print2
pri1 accepting requests since Tue 10 Dec 2013 10:34:24 AM CET
Printer1 accepting requests since Tue 10 Dec 2013 09:47:24 AM CET
Printer2 accepting requests since Tue 10 Dec 2013 09:49:59 AM CET
printer pri1 is idle.  enabled since Tue 10 Dec 2013 10:34:24 AM CET
	Connecting to printer...
printer Printer1 disabled since Tue 10 Dec 2013 09:47:24 AM CET -
	Starting GPL Ghostscript 8.70...
printer Printer2 is idle.  enabled since Tue 10 Dec 2013 09:49:59 AM CET

<note important> Note that the class is automatically destroyed when the last spool is removed from it. </note>

To destroy the previously created spools, the lpadmin command can be used with the x option:

[root@centos ~]# lpadmin -x Printer1
[root@centos ~]# lpadmin -x Printer2
[root@centos ~]# lpadmin -x Pri1
[root@centos ~]# lpstat -t
scheduler is running
no system default destination
lpstat: No destinations added.
lpstat: No destinations added.
lpstat: No destinations added.
lpstat: No destinations added.

Web Interface

CUPS can be entirely configured by using a web interface available at the following address: http://localhost:631 or https://localhost:631.

<note> Use the web interface to re-create all of the previously mentionned Printers and Classes. </note>

Graphical Interface

Red Hat and CentOS provide a graphical interface for configuring CUPS - system-config-printer:

~~DISCUSSION:off~~


<html> <center> Copyright © 2011-2014 Hugh Norris.<br><br> <a rel=“license” href=“http://creativecommons.org/licenses/by-nc-nd/3.0/”><img alt=“Creative Commons License” style=“border-width:0” src=“https://i.creativecommons.org/l/by-nc-nd/3.0/88x31.png” /></a><br />This work is licensed under a <a rel=“license” href=“http://creativecommons.org/licenses/by-nc-nd/3.0/”>Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License</a> </center> </html>

Menu