Description
The Common UNIX Printing System (“CUPS”) is a cross-platform printing solution for all UNIX environments. It is based on the “Internet Printing Protocol” and provides complete printing services to most PostScript and raster printers. CUPS is a replacement for the LPD printing system. It replaces the lpr command with its own and the LPD printer drivers with its own versions.
However, CUPS is similar to LPD in that it uses PostScript as its underlying language for page descriptions. Linux (and UNIX) programs don’t know the difference between CUPS and LPD. This service executes a printer server daemon. The daemon broadcasts information about its printers and classes into the local network. Every machine in the local network which has a CUPS daemon running picks up these signals. Thus it knows which printers are available in the local network. So a CUPS client just needs to start its CUPS daemon and it has access to all the printers on the local network.
# yum install cups # yum install cups-lpd
Service Control
The script for managing the cups service is /etc/init.d/cups. Where printing is required, enabled the cups service to automatically start upon server boot i.e.:
# chkconfig --add cups # chkconfig --list cups cups 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Enable the serivce cups-lpd i.e.:
# chkconfig cups-lpd on
Usage:
# service cups Usage: cups {start|stop|restart|condrestart|reload|status}
Examples:
# service cups status cupsd (pid 2308) is running...
# service cups stop Stopping cups: [ OK ]
# service cups start Starting cups: [ OK ]
# service cups restart Stopping cups: [ OK ] Starting cups: [ OK ]
# service cups condrestart Stopping cups: [ OK ] Starting cups: [ OK ]
# service cups reload Reloading cups: [ OK ]
# service cups status cupsd (pid 3689) is running...
After the service is started, a cupsd daemon runs, listening on it’s default port of 631, e.g.:
# ps -aux|grep cupsd root 17591 0.0 0.7 9704 2080 ? Ss 02:48 0:00 cupsd
# netstat -anp|grep cups tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 17591/cupsd udp 0 0 0.0.0.0:631 0.0.0.0:* 17591/cupsd
Configuration
1. Access control
The central cups daemon configuration file is /etc/cups/cupsd.conf. It’s syntax is comparable to that required by the Apache webserver configuration file. Access control, that decides who may print, is configured using Location sections i.e.:
<Location /> Order Deny,Allow Deny From All Allow From 127.0.0.1 </Location>
Deny statements are handled first, followed by allow statements. By default, access is denied from all hosts, except for 127.0.0.1, the localhost. In the example below, hosts from the localhost (127.0.0.1) and network address space 10.182.121.0/25 are permitted to use printers on the system.
<Location /> Order Deny,Allow Deny From All Allow From 127.0.0.1 Allow From 10.182.121.0/25 </Location>
2. Configuration Tool
Once the cups daemon is started, CUPS may be configured via it’s web interface – http://localhost:631. If prompted, enter root credentials. Printers can be added to the CUPS configuration by clicking on ‘Administrate’, and the ‘Add Printer’ buttons. The web interface promts for additional printer information, i.e.:
Name – the name of the printer.
Location – the physical location of the printer.
Description – a description of the printer
Click the ‘Continue‘ button to configure how the printer is connected. After configuring the printer port, select the printer brand and model. Once the printer configuration is complete, the printer is added to the CUPS configuration. The following is an example cups configuration file after a printer has been added:
$ cat /etc/cups/printers.conf # Printer configuration file for CUPS v1.3.5 # Written by cupsd on 2008-04-01 11:14 <Printer Printer> Info HP printer <- PRINTER BRAND AND MODEL Location 2nd Floor <- LOCATION DeviceURI parallel:/dev/lp0 <- PRINTER ATTACHED TO LOCAL MACHINE State Idle StateTime 1207041285 Accepting Yes Shared Yes JobSheets none none QuotaPeriod 0 PageLimit 0 KLimit 0 OpPolicy default ErrorPolicy stop-printer </Printer>
A corresponding entry now appears in the /etc/printcap file, i.e.:
$ cat /etc/printcap # This file was automatically generated by cupsd(8) from the # /etc/cups/printers.conf file. All changes to this file # will be lost. Printer|HP printer:rm=hostname.cn.oracle.com:rp=Printer: