2. A printing system handles the tasks involved in getting a print job from an application
(or the command line) through the appropriate filters
LPD and LPR Traditionally, UNIX had two printing systems: the BSD Line Printer Daemon (LPD)
and the System V Line Printer system (LPR). Linux adopted these systems at first, and both UNIX
and Linux have seen modifications to and replacements for these systems. Today CUPS is the
default printing system under Fedora/RHEL.
3. 1. CUPS CUPS (Common UNIX Printing System) is a cross-platform print server built around IPP
(next).
2. CUPS provides many printer drivers and can print different types of files, including PostScript.
3. Because it is built on IPP and written to be portable, CUPS runs under many operating
systems, including Linux and Windows. Other UNIX variants, including Mac OS X, use CUPS;
recent versions of Windows include the ability to print to IPP printers.
4. Thus CUPS is an ideal solution for printing in a heterogeneous environment.
5. CUPS provides System V and BSD command-line interfaces and, in addition to IPP, supports
LPD/LPR, HTTP, SMB, and JetDirect (socket) protocols, among others.
4. Network printers Printers connected directly to a network are functionally equivalent to printers
connected to a system running a print server: They listen on the same ports as systems running
print servers, and they queue jobs.
Printers and queues On a modern computing system, when you “send a job to the printer,” you
actually add the job to the list of jobs waiting their turn to be printed on a printer. This list is
called a print queue or simply a queue. The phrase configuring (or setting up) a printer is often
used to mean configuring a (print) queue. This chapter uses these phrases interchangeably.
5. Prerequisites:
Make sure the following packages are installed (most are installed with the base Fedora/RHEL
system):
• cups
• system-config-printer (optional)
• cups-pdf (optional; Fedora only; sets up a virtual PDF printer)
6. The CUPS Web interface requires an X server and a Web browser. Although it is a poor solution,
a text Web browser such as elinks (elinks package) will work too.
cups init script Run chkconfig to cause CUPS (the cupsd daemon) to start when the system goes
into
multiuser mode:
# chkconfig cups on
Start CUPS:
# service cups start
7. Firewall A CUPS server normally uses TCP port 631 for an IPP connection and port 80 for
an LPR/LPD connection. If the CUPS server system accepts print jobs from remote
systems and is running a firewall, you need to open one or both of these ports.
PDF printer You can set up a virtual PDF printer by installing the cups-pdf package, or you can
set up this printer manually.
8. Configuring a Printer Using system-config-
printer
Main menu: System Administration Printing (RHEL) or give the command
systemconfig-printer from a terminal emulator or Run Application window (ALT-F2).
9.
10. Default printer Highlight a printer in the Printing window and select menubar: Printer Set as
Default from the window menu to specify the highlighted printer as the default printer. If just
one printer appears in the Printing window, it is the default printer; you do not have to set it up
as such.
Server Settings Select menubar: Server Settings from the Printing window to display the Server
Settings window. The top two check boxes in this window specify whether systemconfig-
printer displays printers that are shared by other systems and whether the local system
publishes printers it shares. You control whether a specific printer is shared from the Policies
selection of the Printer Properties window (next).
11. Configuration Selections
Select menubar: Printer Properties to display the Printer Properties window
This section describes the six selections found in the frame at the left side of the
Printer Properties window. These selections allow you to configure the printer you
chose in the Printing window
12. The text boxes labeled Description and Location hold information that can help users identify
The printer. The system does not use this information; change it as you like. For example,
it might be helpful to put the physical location of the printer, such as Sam’s Office, in the text
box labeled Location. The text boxes labeled Device URI and Make and Model specify the
location of the printer on the computer or network and type of the printer.
13.
14. Policies The Policies selection enables you to control printer state, sharing, and banners.
Under the word State are check boxes labeled Enabled, Accepting jobs, and Shared.
Putting a tick in the check box labeled Shared shares the printer with other systems if the
local system publishes shared printers (see “Server Settings”). The Policies tab also controls
whether the printer prints banners before and after jobs and what CUPS does when the printer
reports an error.
15. Access Control The Access Control selection enables you to set the policy for printer access. By
default, anyone can use the printer. To restrict access, you can create a blacklist of
users who are not allowed to use it. Alternatively, you can prohibit anyone from
using the printer and then create a whitelist of users who are allowed to use it.
Printer Options The Printer Options selection controls image quality, paper size and source
(tray), and other generic printer options.
16.
17. Setting Up a Local or Remote Printer
This section describes how to set up three types of printers for local use: a printer
attached to the local system, a printer hosted by another system, and a printer that
resides on the local network (a network printer).
The system-config-printer utility looks for printers attached to the system or the local network. It
then asks if you want to adjust the firewall so the local system can detect printers on the
network (Fedora only) and displays the New Printer window
18. Specifying a URI The easiest way to locate a remote printer that is not listed is to select Find
Network Printer under Network Printer in the frame labeled Select Device. Then enter in the
text box labeled Host the name of the host the printer is attached to (the server) or,
for a network printer, the name of the printer. You can specify an IP address instead of
a hostname.
Click Find. If it finds a printer, system-config-printer displays the name of
the printer under Network Printer and fills in information about the printer on the
right side of the window.
19.
20. If the printer is not listed, select Other (for a local printer) or one of the selections
under Network Printer (for a remote printer) from the frame labeled Select Device;
system-config-printer displays appropriate text boxes on the right side of the window.
All selections under Network Printer require you to specify a Host and a Queue or
Port number. These values locate the printer on the network.
21. To specify the queue for an LPD/LPR printer, use the form printer-name; for an IPP
printer, use the form /printers/printer-name; for an HP JetDirect-compatible network
printer, specify the printer-name and Port number. Replace printer-name with the
name of the printer on the server.
If you are unsure of the name of a printer, give the command lpstat –p on the server to
display the names of all printers on that system. After selecting or specifying a printer,
click the button labeled Verify (if present) to make sure the printer is accessible and
then click Forward. The system-config-printer utility searches for the printer driver.
22.
23. At this point, the system-config-printer utility closes the New Printer window, asks if
you want to print a test page, and displays the new printer in the Printing window.
If you have more than one print queue and want to set up the new print queue to be
the default, highlight the printer and select menubar: Printer Set As Default
24. Sharing CUPS Printers
Display the Server Settings window by selecting menubar: Server Settings and put a tick in the
Check box labeled Publish shared printers connected to this system. Using this technique
allows you to chose whether to share each printer.
25. IPP facilitates remote printing. The Listen directive in the CUPS configuration file,
/etc/cups/cupsd.conf, specifies which IP address and port or which domain socket path
CUPS binds to and accepts requests on. The Listen directive has the following format:
Listen IP:port | path
26. where IP is the IP address that CUPS accepts connections on, port is the port number
that CUPS listens on for connections on IP, and path is the pathname of the domain
socket CUPS uses to communicate with printers. CUPS typically uses port 631 and by
default binds to localhost. Thus it accepts connections from the loopback service of
the local system only. CUPS uses /var/run/cups/cups.sock, a local domain socket, to
communicate with local printers. It can also use a Port directive to specify the port
number it listens to for HTTP requests.
27. $ grep -i listen /etc/cups/cupsd.conf
# Only listen for connections from the local machine.
Listen localhost:631
Listen /var/run/cups/cups.sock
28. To allow other systems to connect to the CUPS server on the local system, you must
instruct CUPS to bind to an IP address that the other systems can reach. First
remove or comment out the Listen localhost:631 directive; leave the other Listen
directive in place:
# Listen localhost:631
Listen /var/run/cups/cups.sock
In place of the commented-out Listen directive, use an access control list to permit
only selected machines to connect to local printers. An access control list is
29. defined inside a <Location> container (see page 934 for the Apache equivalent).
The following example allows only the system at IP address 192.168.1.101 and
the local system to print to the specified printer.
<Location />
Order Allow,Deny
# Allow access from the local system and 192.168.1.101
Allow from localhost
Allow from 192.168.1.101
# Uncomment the following line to permit access from all systems
# Allow @LOCAL
</Location>
The @LOCAL macro is internal to CUPS and specifies the local system. This macro
accepts communication from any address that resolves to the local system. Specify
Allow @LOCAL to share the printer with all systems.
30. Print from Windows
Print Using CUPS
Modern versions of Windows (2000 and later) support IPP and as a result can communicate
directly with CUPS. To use this feature, you must have CUPS configured on
the Linux print server to allow remote IPP printing; you also need to create a new
printer on the Windows system that points to the IP address of the Linux print server
First set up the /etc/cups/cupsd.conf file to allow network printing from a client, as
explained in “Sharing CUPS Printers”
31. Windows XP From Windows XP, go to Control PanelPrinters and Faxes and click Add Printer.
Click Next in the introductory window and select A network printer or a printer
attached to another computer. Click Next. Select Connect to a printer on the Internet
or on a home or office network. Continue following the next paragraph at
“Enter URL.”
32. Windows 7 From Windows 7, go to Control PanelDevices and Printers and click Add a
printer. Click Add a network, wireless, or Bluetooth printer. Assuming Windows
does not find the printer, click The printer that I want isn’t listed. Click the radio
button labeled Select a shared printer by name.
33. Enter URL Enter the following information in the text box (under Windows XP it is labeled URL):
http://hostname:631/printers/printer-name
where hostname is the name or IP address of the Linux CUPS server system and
printer-name is the name of the printer on that system. For example, for the printer
named dog88 on the system named dog at IP address 192.168.0.12, you could enter
http://dog:631/printers/dog88 or http://192.168.0.12:631/printers/dog88. If you
use a hostname, it must be defined in the hosts file on the Windows machine. Click
Next. Windows requests that you specify the manufacturer and model of printer or
provide a driver for the printer. If you supply a printer driver, use the Windows version
of the driver.
34. Print Using Samba
Samba must be set up so that the Windows user who will be printing is mapped to a
Linux user (including mapping the Windows guest user to the Linux user nobody).
Windows supports printer sharing via SMB, which allows a printer to be shared
transparently between Windows systems using the same mechanism as file sharing.
Samba allows Windows users to use printers connected to Linux systems just as
they would use any other shared printers
35. When you use rpm to install Samba, it creates a directory named /var/spool/samba
that is owned by the root account and that anyone can read from and write to
$ ls -ld /var/spool/samba
drwxrwxrwt. 2 root root 4096 02-03 15:23 /var/spool/samba
36. Under Fedora, put the following two lines in the [global] section of the /etc/samba/smb.conf
file. Under RHEL, these lines are set up by default, you need only change the printcap name as
shown.
[global]
...
printing = cups
printcap name = cups
37. The printer’s share is listed in the [printers] section in smb.conf. In the following
example, the path is the path Samba uses as a spool directory and is not a normal
share path. The settings allow anyone, including guest, to use the printer. The
[printers] section in the default smb.conf file has the following entries, which are
appropriate for most setups:
38. [printers]
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
writable = no
printable = yes
39. Printing to Windows
CUPS views a printer on a Windows machine exactly the same way it views any
other printer. The only difference is the URI you need to specify when connecting it.
To configure a printer connected to a Windows machine, click the Administration
tab in the CUPS Web interface and select Add Printer, just as you would for a local
printer.
40. When you are asked to select the device, choose Windows Printer via SAMBA.
Enter the URI of the printer in the following format:
smb://windows_system/printer_name
where windows_system can be an IP address or a hostname. After you have added
the printer, you can use it as you would any other printer.