Configuring a Print Server - Becoming a Linux Server Administrator - Linux Bible 9th Ed (2015)

Linux Bible 9th Ed (2015)

Part IV. Becoming a Linux Server Administrator

Chapter 16. Configuring a Print Server


1. Understanding printing in Linux

2. Setting up printers

3. Using printing commands

4. Managing document printing

5. Sharing printers

You can configure your Linux system to use printers that are connected directly to it (via a USB or parallel port) or that are available for printing over the network. Likewise, any printer you configure on your local system can be shared with users on other Linux, Windows, or Mac systems by opening up your printer as a print server.

You configure a printer as a native Linux printer in Fedora, RHEL, Ubuntu, and other Linux systems with the Common UNIX Printing System (CUPS). To configure a printer to work as a Microsoft Windows style of print server, you can use the Samba service in Linux.

This chapter focuses on CUPS. In particular, it shows you the graphical front end to CUPS, called the Print Settings window, which comes with Fedora, Red Hat Enterprise Linux, and other Linux distributions. Using Print Settings, you can also configure your printers as print servers so people can print to your printer from their own computers.

If you don't have a desktop or want to print from within a shell script, this chapter shows you how to use printing commands. From the command line, print commands such as lpr are available for carrying out printing. Commands also exist for querying print queues (lpq), manipulating print queues (lpc), and removing print queues (lprm).

Common UNIX Printing System

CUPS has become the standard for printing from Linux and other UNIX-like operating systems. It was designed to meet today's needs for standardized printer definitions and sharing on Internet Protocol–based networks (as most computer networks are today). Nearly every Linux distribution today comes with CUPS as its printing service. Here are some of the service's features:

· IPP—CUPS is based on the Internet Printing Protocol (, a standard that was created to simplify how printers can be shared over IP networks. In the IPP model, printer servers and clients who want to print can exchange information about the model and features of a printer using HTTP (that is, web content) protocol. A server can also broadcast the availability of a printer so a printing client can easily find a list of locally available printers without configuration.

· Drivers—CUPS also standardized how printer drivers are created. The idea was to have a common format that could be used by printer manufacturers so that a driver could work across all different types of UNIX systems. That way, a manufacturer had to create the driver only once to work for Linux, Mac OS X, and a variety of UNIX derivatives.

· Printer classes—You can use printer classes to create multiple print server entries that point to the same printer or one print server entry that points to multiple printers. In the first case, multiple entries can each allow different options (such as pointing to a particular paper tray or printing with certain character sizes or margins). In the second case, you can have a pool of printers so that printing is distributed. In this instance, a malfunctioning printer or a printer that is dealing with very large documents won't bring all printing to a halt. CUPS also supports implicit classes, which are print classes that form by merging identical network printers automatically.

· Printer browsing—With printer browsing, client computers can see any CUPS printers on your local network with browsing enabled. As a result, clients can simply select the printers they want to use from the printer names broadcast on the network, without needing to know in advance what the printers are named and where they are connected. You can turn off the feature to prevent others on the local network from seeing a printer.

· UNIX print commands—To integrate into Linux and other UNIX environments, CUPS offers versions of standard commands for printing and managing printers that have been traditionally offered with UNIX systems.

Instead of using the Print Settings window, you can configure CUPS printing in other ways as well:

· Configuring CUPS from a browser—The CUPS project itself offers a web-based interface for adding and managing printers. With the cupsd service running, type localhost:631 from a web browser on the computer running the CUPS service to manage printing. (See the section “Using web-based CUPS administration” later in this chapter.)

· Configuring CUPS manually—You also can configure CUPS manually (that is, edit the configuration files and start the cupsd daemon from the command line). Configuration files for CUPS are contained in the /etc/cups directory. In particular, you might be interested in the cupsd.conf file, which identifies permission, authentication, and other information for the printer daemon, and printers.conf, which identifies addresses and options for configured printers. Use the classes.conf file to define local printer classes.

Coming from Windows

You can print to CUPS from non-UNIX systems as well. For example, you can use a PostScript printer driver to print directly from a Windows system to your CUPS server. You can use CUPS without modification by configuring the Windows computer with a PostScript driver that uses http://printservername:631/printers/targetPrinter as its printing port.

You may also be able to use the native Windows printer drivers for the printer instead of the PostScript driver. If the native Windows driver does not work right out of the box on your CUPS print queue, you can create a Raw Print Queue under CUPS and use that instead. The Raw Print Queue directly passes through the data from the Windows native print driver to the printer.

To use CUPS, you must have the cups package installed in Fedora or RHEL. Most desktop Linux distributions include CUPS during the initial system install. If it is not installed in a Fedora or RHEL install, install it by typing the following:

# yum install cups

Setting Up Printers

Although using the printer administration tools specifically built for your distribution is usually best, many Linux systems simply rely on the tools that come with the CUPS software package.

This section explores how to use CUPS web-based administration tools that come with every Linux distribution and then examines the Print Settings tool system-config-printer, which is available with Fedora and Red Hat Enterprise Linux systems to enable you to set up printers. In some cases, no configuration is necessary, because connected printers can be automatically detected and configured. To install the Print Settings tool, as root type:

# yum install system-config-printer

Adding a printer automatically

CUPS printers can be configured to automatically broadcast their availability on the network so a client system can detect and use them without configuration. Connect a USB printer to your computer, and the printer can be automatically detected and made available. In fact, if you attach a local printer in Fedora and the print driver is not yet installed, you are prompted to install the software packages needed to use the printer.

The first time you go to print a document or view your Print Settings tool, the printers are ready to use. Further configuration can be done using the web-based CUPS administration tool or the Print Settings window.

Using web-based CUPS administration

CUPS offers its own web-based administrative tool for adding, deleting, and modifying printer configurations on your computer. The CUPS print service (using the cupsd daemon) listens on port 631 to provide access to the CUPS web-based administrative interface and share printers.

If CUPS is already running on your computer, you can immediately use CUPS web-based administration from your web browser. To see whether CUPS is running and to start setting up your printers, open a web browser on the local computer and type the following into its location box: http://localhost:631/.

A prompt for a valid login name and password may appear when you request functions that require it. If so, type the root login name and the root user's password, and click OK. A screen similar to the one shown in Figure 16.1 appears.


Figure 16.1 CUPS provides a web-based administration tool.

By default, web-based CUPS administration is available only from the local host. To access web-based CUPS administration from another computer, from the main CUPS page, select the Administration tab, select the check box next to Allow remote administration, and select the Change Settings button. Then, from a remote browser, you can access the CUPS Administration page by going to port 631 on the CUPS server (for example,

You may need to restart CUPs for the change to take effect: systemctl restart cups.service. If you are not already running the browser as the root user, you must also enter the root user name and password.

To configure a printer that is not automatically detected, you can add a printer from the Administration screen. With the Administration screen displayed, you can add a printer as follows:

1. Click the Add Printer button. The Add New Printer screen appears.

2. Select the device to which the printer is connected. The printer can be connected locally to a parallel, SCSI, serial, or USB port directly on the computer. Alternatively, you can select a network connection type for Apple printers (appSocket/HP JetDirect), Internet Printing Protocol (http or ipp), or a Windows printer (using Samba or SMB).

3. If prompted for more information, you may need to further describe the connection to the printer. For example, you may need to enter the baud rate and parity for a serial port, or you might be asked for the network address for an IPP or Samba printer.

4. Type a Name, Location, and Description for the printer; select if you want to share this printer, and click Continue.

5. Select the make of the print driver. If you don't see the manufacturer of your printer listed, choose PostScript for a PostScript printer or HP for a PCL printer. For the manufacturer you choose, you can select a specific model.

6. Set options. If you are asked to set options for your printer, you may do so. Then select Set Printer Options to continue.

7. Your printer should be available. If the printer is added successfully, click the name of your printer to have the new printer page appear; from the printer page, you can select Maintenance or Administration to print a test page or modify the printer configuration.

With the basic printer configuration done, you can now do further work with your printers. Here are a few examples of what you can do:

· List print jobs. Click Show All Jobs to see what print jobs are currently active from any of the printers configured for this server. Click Show Completed Jobs to see information about jobs that are already printed.

· Create a printer class. Click the Administration tab, choose Add Class, and identify a name, description, and location for a printer class. From the list of Printers (Members) configured on your server, select the ones to go into this class.

· Cancel or move a print job. If you print a 100-page job by mistake or if the printer is spewing out junk, the Cancel feature can be very handy. Likewise, if you sent a print job to the wrong printer, the Move Job selection can be useful. From the Administration tab, click Manage Jobs; then click Show Active Jobs to see what print jobs are currently in the queue for the printer. Select the Cancel Job button next to the print job you want to cancel, or select Move Job to move the print job to a different printer.

· View printers. You can click the Printers tab from the top of any of the CUPS web-based administration pages to view the printers you have configured. For each printer that appears, you can select Maintenance or Administrative tasks. Under Maintenance, click Pause Printer (to stop the printer from printing but still accept print jobs for the queue), Reject Jobs (to not accept any further print jobs for the moment), Move All Jobs (to move them to another printer), Cancel All Jobs (to delete all print jobs), or Print Test Page (to print a page). Figure 16.2 shows the information on the Printers tab for a specific printer.


Figure 16.2 You can do administration tasks from the Printers tab.

Using the Print Settings window

If you are using Fedora, RHEL, or other Red Hat–based systems, you can use the Print Settings window to set up your printers. In fact, I recommend that you use it instead of CUPS web administration because the resulting printer configuration files are tailored to work with the way the CUPS service is started on those systems.

After the package is installed (yum install system-config-printer), to install a printer from your GNOME desktop, start the Print Settings window by typing Print Settings from the Activity screen, or as root user by typing system-config-printer. This tool enables you to add and delete printers and edit printer properties. It also enables you to send test pages to those printers to make sure they are working properly.

The key here is that you are configuring printers that are managed by your print daemon (cupsd for the CUPS service). After a printer is configured, users on your local system can use it. You can refer to the section “Configuring Print Servers” to learn how to make the server available to users from other computers on your network.

The printers that you set up can be connected directly to your computer (as on a USB port) or to another computer on the network (for example, from another UNIX system or Windows system).

Configuring local printers with the Print Settings window

Add a local printer (in other words, a printer connected directly to your computer) with the Print Settings window using the procedure that follows.

Adding a local printer

To add a local printer from a GNOME desktop in Fedora 21, follow these steps:

1. Select Print Settings from the Activities screen or type the following as root user from a Terminal window:

# system-config-printer &

The Printing window appears.

2. Click Add. (If asked, select the button to Adjust Firewall to allow access to the printer port 631.) A New Printer window appears.

3. If the printer you want to configure is detected, simply select it and click Forward. If it is not detected, choose the device to which the printer is connected (LPT #1 and Serial Port #1 are the first parallel and serial ports, respectively) and click Forward. (Type /usr/sbin/lpinfo -v | less in a shell to see printer connection types.) You are asked to identify the printer's driver.

4. To use an installed driver for your printer, choose Select Printer From Database, and then choose the manufacturer of your printer. As an alternative, you could select Provide PPD File and supply your own PPD file (for example, if you have a printer that is not supported in Linux and you have a driver that was supplied with the printer). PPD stands for PostScript Printer Description. Select Forward to see a list of printer models from which you can choose.


If your printer doesn't appear on the list but supports PCL (HP's Printer Control Language), try selecting one of the HP printers (such as HP LaserJet). If your printer supports PostScript, select PostScript printer from the list. Selecting Raw Print Queue enables you to send documents that are already formatted for a particular printer type to a specific printer.

5. With your printer model selected, click the driver you want to use with that printer, and then click Forward to continue.

6. Add the following information, and click Forward:

· Printer Name—Add the name you want to give to identify the printer. The name must begin with a letter, but after the initial letter, it can contain a combination of letters, numbers, dashes (-), and underscores (_). For example, an HP printer on a computer named maple could be named hp-maple.

· Description—Add a few words describing the printer, such as its features (for example, an HP LaserJet 2100M with PCL and PS support).

· Location—Add some words that describe the printer's location (for example, “In Room 205 under the coffeepot”).

7. When the printer is added, click No or Yes if you're prompted to print a test page. The new printer entry appears in the Print Settings window. Double-click the printer to see the Properties window for that printer, as shown in Figure 16.3.

8. If you want the printer to be your default printer, right-click the printer and select Set As Default. As you add other printers, you can change the default printer by selecting the one you want and Set As Default again.

9. Make sure printing is working. Open a Terminal window and use the lpr command to print a file (such as lpr /etc/hosts). (If you want to share this printer with other computers on your network, refer to the section “Configuring Print Servers,” later in this chapter.)


Figure 16.3 The Printer Properties window after adding a printer.

Editing a local printer

After double-clicking the printer you want to configure, choose from the following menu options to change its configuration:

· Settings—The Description, Location, Device URI, and Make and Model information you created earlier are displayed in this dialog box.

· Policies—Click Policies to set the following items:

· State—Select check boxes to indicate whether the printer will print jobs that are in the queue (Enabled), accept new jobs for printing (Accepting Jobs), or be available to be shared with other computers that can communicate with your computer (Shared). You also must select Server Settings and click the Share Published printers connected to this system check box before the printer will accept print jobs from other computers.

· Policies—In case of error, the stop-printer selection causes all printing to that printer to stop. You can also select to have the job discarded (abort-job) or retried (retry-job) in the event of an error condition.

· Banner—There are no starting or ending banner pages by default for the printer. Choose starting or ending banner pages that include text such as Classified, Confidential, Secret, and so on.

· Access Control—If your printer is a shared printer, you can select this window to create a list that either allows users access to the printer (with all others denied) or denies users access to the printer (with all others allowed).

· Printer Options—Click Printer Options to set defaults for options related to the printer driver. The available options are different for different printers. Many of these options can be overridden when someone prints a document. Here are examples of a few of the options you might (or might not) have available:

· Watermark—Several Watermark settings are available to enable you to add and change watermarks on your printed pages. By default, Watermark and Overlay are off (None). By selecting Watermark (behind the text) or Overlay (over the text), you can set the other Watermark settings to determine how watermarks and overlays are done. Watermarks can go on every page (All) or only the first page (First Only). Select Watermark Text to choose what words are used for the watermark or overlay (Draft, Copy, Confidential, Final, and so on). You can then select the font type, size, style, and intensity of the watermark or overlay.

· Resolution Enhancement—You can use the printer's current settings or choose to turn resolution enhancement on or off.

· Page Size—The default is U.S. letter size, but you can also ask the printer to print legal size, envelopes, ISO A4 standard, or several other page sizes.

· Media Source—Choose which tray to print from. Select Tray 1 to insert pages manually.

· Levels of Gray—Choose to use the printer's current levels of gray or have enhanced or standard gray levels turned on.

· Resolution—Select the default printing resolution (such as 300, 600, or 1,200 dots per inch). Higher resolutions result in better quality but take longer to print.

· EconoMode—Either use the printer's current setting or choose a mode where you save toner or one where you have the highest possible quality.

· Job Options—Click Job Options to set common default options that will be used for this printer if the application printing the job doesn't already set them. These include Common Options (number of copies, orientation, scale to fit, and pages per side), Image Options (scaling, saturation, hue, and gamma), and Text Options (characters/inch, lines/inch, and margin settings).

· Ink/Toner Levels—Click Ink/Toner Levels to see information on how much ink or toner your printer has left. (Not all printers report these values.)

Click Apply when you are satisfied with the changes you made to the local printer.

Configuring remote printers

To use a printer that is available on your network, you must identify that printer to your Linux system. Supported remote printer connections include Networked CUPS (IPP) printers, Networked UNIX (LPD) printers, Networked Windows (Samba) printers, and JetDirect printers. (Of course, both CUPS and UNIX print servers can be run from Linux systems as well as other UNIX systems.)

In each case, you need a network connection from your Linux system to the servers to which those printers are connected. To use a remote printer requires that someone set up that printer on the remote server computer. See the section “Configuring Print Servers” later in this chapter for information on how to do that on your Linux server.

Use the Print Settings window (system-config-printer) to configure each of the remote printer types. This is how it is done in Fedora 21:

1. From the GNOME 3 Activities screen, type Print Settings and press Enter.

2. Click Add. The New Printer window appears.

3. Depending on the type of ports you have on your computer, select one of the following:

· LPT #1—Use this for a printer connected to your parallel port.

· Serial Port #1—Use this for a printer connected to your serial port.

· Network Printer—Under this heading, you can search for network printers (by hostname or IP address) or type in the URI for several different printer types:

§ Find Network Printer—Instead of entering a printer URI, you can provide a hostname or IP address for the system that has the printer you want to print to. Any printers found on that host appear on the window, ready for you to add.

§ AppleSocket/HP JetDirect—Use this for a JetDirect printer.

§ Internet Printing Protocol (IPP)—Use this for a CUPS or other IPP printer. Most Linux and Mac OS X printers fall into this category.

§ Internet Printing Protocol (HTTPS)—Use this for a CUPS or other IPP printer being shared over a secure connection (valid certificates required).

§ LPD/LPR Host or Printer—Use this for a UNIX printer.

§ Windows Printer via SAMBA—Use this for a Windows system printer.

Continue with the steps in whichever of the following sections is appropriate.

Adding a remote CUPS printer

If you chose to add a CUPS (IPP) printer that is accessible over your local network from the Print Settings window, you must add the following information to the window that appears:

· Host—This is the hostname of the computer to which the printer is attached (or otherwise accessible). This can be an IP address or TCP/IP hostname for the computer. The TCP/IP name is accessible from your /etc/hosts file or through a DNS name server.

· Queue—This is the printer name on the remote CUPS print server. CUPS supports printer instances, which allows each printer to have several sets of options. If the remote CUPS printer is configured this way, you can choose a particular path to a printer, such as hp/300dpi or hp/1200dpi. A slash character separates the print queue name from the printer instance.

Complete the rest of the procedure as you would for a local printer (see the section “Adding a local printer” earlier in this chapter).

Adding a remote UNIX (LDP/LPR) printer

If you chose to add a UNIX printer (LPD/LPR) from the Print Settings window, you must add the following information to the window that appears:

· Host—This is the IP address or hostname of the computer to which the printer is attached (or otherwise accessible). The hostname is accessible from your /etc/hosts file or through a DNS name server. Select the Probe button to search for the host.

· Queue—This is the printer name on the remote UNIX computer.

Complete the rest of the procedure as you would for a local printer (see the section “Adding a local printer” earlier in this chapter).


If the print job you send to test the printer is rejected, the print server computer may not have allowed you access to the printer. Ask the remote computer's administrator to add your hostname to the /etc/lpd.perms file. (Type lpq -P printer to see the status of your print job.)

Adding a Windows (SMB) printer

Enabling your computer to access an SMB printer (the Windows printing service) involves adding an entry for the printer in the Select Connection window.

When you choose to add a Windows printer to the Print Settings window (Windows Printer via Samba), select Browse to see a list of computers on your network that have been detected as offering SMB services (file and/or printing service). You can configure the printer from this window as follows:

1. Type the URI of the printer, excluding the leading smb://. For example, you might type /host1/myprinter or /mygroup/host1/myprinter.

2. Select either Prompt user if authentication is required or Set authentication details now.

3. If you chose to Set authentication details now, fill in the username and password needed to access the SMB printer; then click Verify to check that you can authenticate to the server.

4. Click Forward to continue.

Alternatively, you can identify a server that does not appear on the list of servers. Type the information needed to create an SMB URI that contains the following information:

· Workgroup—This is the workgroup name assigned to the SMB server. Using the workgroup name isn't necessary in all cases.

· Server—This is the NetBIOS name or IP address for the computer, which may or may not be the same as its TCP/IP name. To translate this name into the address needed to reach the SMB host, Samba checks several places where the name may be assigned to an IP address. Samba checks the following (in the order shown) until it finds a match: the local /etc/hosts file, the local /etc/lmhosts file, a WINS server on the network, and responses to broadcasts on each local network interface to resolve the name.

· Share—This is the name under which the printer is shared with the remote computer. It may be different from the name by which local users of the SMB printer know the printer.

· User—A username is required by the SMB server system to give you access to the SMB printer. A username is not necessary if you are authenticating the printer based on share-level rather than user-level access control. With share-level access, you can add a password for each shared printer or file system.

· Password—Use the password associated with the SMB username or the shared resource, depending on the kind of access control being used.


When you enter a User and Password for SMB, the information is stored unencrypted in the /etc/cups/printers.conf file. Be sure that the file remains readable only by root.

The following is an example of the SMB URI you could add to the SMB:// box:


The URI shown here identifies the username (jjones), the user's password (my9passswd), the workgroup (FSTREET), the server (NS1), and the printer queue name (hp).

Complete the rest of the procedure as you would for a local printer (see the section “Adding a local printer” earlier in this chapter).

If everything is set up properly, you can use the standard lpr command to print the file to the printer. Using this example, employ the following form for printing:

$ cat | lpr -P NS1-PS


If you are receiving failure messages, make sure the computer to which you are printing is accessible. For the Printer NS1 hp example, you can type smbclient -L NS1 -U jjones. Then type the password (my9passswd, in this case). The –L asks for information about the server; the –U jjones says to log in the user jjones. If you get a positive name query response after you enter a password, you should see a list of shared printers and files from that server. Check the names, and try printing again.

Working with CUPS Printing

Tools such as CUPS web-based administration and the Print Settings window effectively hide the underlying CUPS facility. Sometimes, however, you want to work directly with the tools and configuration files that come with CUPS. The following sections describe how to use some special CUPS features.

Configuring the CUPS server (cupsd.conf)

The cupsd daemon process listens for requests to your CUPS print server and responds to those requests based on settings in the /etc/cups/cupsd.conf file. The configuration variables in the cupsd.conf file are in the same form as those in the Apache configuration file (httpd.conf or apache2.conf). Type man cupsd.conf to see details on any of the settings.

The Print Settings window adds access information to the cupsd.conf file. For other Linux systems, or if you don't have a desktop on your server, you may need to configure the cupsd.conf file manually. You can step through the cupsd.conf file to further tune your CUPS server. Most of the settings are optional or can just be left as the default. Let's look at some of the settings that you can use in the cupsd.conf file.

No classification is set by default. With the classification set to topsecret, you can have Top Secret displayed on all pages that go through the print server:

Classification topsecret

Other classifications you can substitute for topsecret include classified, confidential, secret, and unclassified.

The ServerCertificate and ServerKey lines (not set by default) can be set up to indicate where the certificate and key are stored, respectively:

ServerCertificate /etc/cups/ssl/server.crt

ServerKey /etc/cups/ssl/server.key

Activate these two lines if you want to do encrypted connections. These files are automatically generated for your system when you first start the cupsd service. So you can just use those files, or you can generate your own certificate and key and set the path to ServerCertificate and ServerKey entries. Using a certificate and key lets you share your printer as an HTTPS IPP printer.

The term browsing refers to the act of broadcasting information about your printer on your local network and listening for other print servers' information. Browsing is on by default only for the local host (@LOCAL). You can allow CUPS browser information (BrowseAllow) for additional selected addresses. Browsing information is broadcast, by default, on address Here are examples of several browsing settings:

Browsing On

BrowseProtocols cups

BrowseOrder Deny,Allow

BrowseAllow from @LOCAL


Listen *:631

To enable web-based CUPS administration and to share printers with others on the network, the cupsd daemon can be set to listen on port 631 for all network interfaces to your computer based on this entry: Listen *:631. By default, it listens on the local interface only on many Linux systems (Listen localhost:631). For Fedora, CUPS listens on all interfaces by default.

By turning on BrowseRelay (it's off by default), you can allow CUPS browse information to be passed among two or more networks. The source-address and destination-address can be individual IP addresses or can represent network numbers:

BrowseRelay source-address destination-address

This is a good way to enable users on several connected LANs to discover and use printers on other nearby LANs.

You can allow or deny access to different features of the CUPS server. An access definition for a CUPS printer (created from the Print Settings window) might appear as follows:

<Location /printers/ns1-hp1>

Order Deny,Allow

Deny From All

Allow From

AuthType None


Here, printing to the ns1-hp1 printer is allowed only for users on the local host ( No password is needed (AuthType None). To allow access to the administration tool, CUPS must be configured to prompt for a password (AuthType Basic).

Starting the CUPS server

For Linux systems that use SystemV-style startup scripts (such as earlier releases of Fedora and RHEL), starting and shutting down the CUPS print service is pretty easy. Use the chkconfig command to turn on CUPS so it starts at each reboot. Run the cups startup script to have the CUPS service start immediately. In RHEL 6.x or earlier, type the following as root user:

# chkconfig cups on

# service cups start

If the CUPS service was already running, you should use restart instead of start. Using the restart option is also a good way to reread any configuration options you may have changed in the cupsd.conf file (although, if CUPS is already running, service cups reloadrereads configuration files without restarting).

In Fedora 21 and RHEL 7, you use the systemctl command instead of service to start and stop services:

# systemctl status cups.service

* cups.service - CUPS Printing Service

Loaded: loaded (/usr/lib/systemd/system/cups.service; enabled)

Active: active (running) since Sat 2016-07-23 22:41:05 EDT; 18h


Main PID: 20483 (cupsd)

Status: "Scheduler is running..."

CGroup: /system.slice/cups.service

120483 /usr/sbin/cupsd -f

You can tell the CUPS service is running because the status shows the cupsd daemon active with PID 20483. If that service were not running, you could start the CUPS service as follows:

# systemctl start cups.service

See Chapter 15, “Starting and Stopping Services,” for more information on the systemctl and service commands for working with services.

Configuring CUPS printer options manually

If your Linux distribution doesn't have a graphical means of configuring CUPS, you can edit configuration files directly. For example, when a new printer is created from the Print Settings window, it is defined in the /etc/cups/printers.conf file. This is what a printer entry looks like:

<DefaultPrinter printer>

Info HP LaserJet 2100M

Location HP LaserJet 2100M in hall closet

DeviceURI parallel:/dev/lp0

State Idle

Accepting Yes

Shared No

JobSheets none none

QuotaPeriod 0

PageLimit 0

KLimit 0


This is an example of a local printer that serves as the default printer for the local system. The Shared No value is set because the printer is currently available only on the local system. The most interesting information relates to DeviceURI, which shows that the printer is connected to parallel port /dev/lp0. The state is Idle (ready to accept printer jobs), and the Accepting value is Yes (the printer is accepting print jobs by default).

The DeviceURI has several ways to identify the device name of a printer, reflecting where the printer is connected. Here are some examples listed in the printers.conf file:

DeviceURI parallel:/dev/plp

DeviceURI serial:/dev/ttyd1?baud=38400+size=8+parity=none+flow=soft

DeviceURI scsi:/dev/scsi/sc1d6l0

DeviceURI socket://hostname:port

DeviceURI tftp://hostname/path

DeviceURI ftp://hostname/path

DeviceURI http://hostname[:port]/path

DeviceURI ipp://hostname/path

DeviceURI smb://hostname/printer

The first three examples show the form for local printers (parallel, serial, and scsi). The other examples are for remote hosts. In each case, hostname can be the host's name or IP address. Port numbers or paths identify the locations of each printer on the host.


If you find that you cannot print because a particular printer driver is not supported in CUPS, you can set up your printer to accept jobs in raw mode. This can work well if you are printing from Windows clients that have the correct print drivers installed. To enable raw printing in CUPS, uncomment the following line in the /etc/cups/mime.types file in Linux:


and uncomment the following line in the /etc/cups/mime.convs file:

application/octet-stream application/vnd.cups-raw 0 -

After that, you can print files as raw data to your printers without using the -oraw option to print commands.

Using Printing Commands

To remain backward compatible with older UNIX and Linux printing facilities, CUPS supports many of the old commands for working with printing. Most command-line printing with CUPS can be performed with the lpr command. Word processing applications such as LibreOffice, OpenOffice, and AbiWord are set up to use this facility for printing.

You can use the Print Settings window to define the filters needed for each printer so that the text can be formatted properly. Options to the lpr command can add filters to properly process the text. Other commands for managing printed documents include lpq (for viewing the contents of print queues), lprm (for removing print jobs from the queue), and lpc (for controlling printers).

Printing with lpr

You can use the lpr command to print documents to both local and remote printers (provided the printers are configured locally). Document files can be either added to the end of the lpr command line or directed to the lpr command using a pipe (|). Here's an example of a simple lpr command:

$ lpr

When you specify just a document file with lpr, output is directed to the default printer. As an individual user, you can change the default printer by setting the value of the PRINTER variable. Typically, you add the PRINTER variable to one of your startup files, such as$HOME/.bashrc. Adding the following line to your .bashrc file, for example, sets your default printer to lp3:

export PRINTER=lp3

To override the default printer, specify a particular printer on the lpr command line. The following example uses the -P option to select a different printer:

$ lpr -P canyonps

The lpr command has a variety of options that enable lpr to interpret and format several different types of documents. These include -# num, where num is replaced by the number of copies to print (from 1 to 100) and -l (which causes a document to be sent in raw mode, presuming that the document has already been formatted). To learn more options to lpr, type man lpr.

Listing status with lpc

Use the lpc command to list the status of your printers. Here is an example:

$ /usr/sbin/lpc status


printer is on device 'usb' speed -1

queuing is enabled

printing is disabled

no entries

daemon present


printer is on device '/dev/null' speed -1

queuing is enabled

printing is disabled

no entries

daemon present

This output shows two active printers. The first (hp) is connected to a local USB port. The second (deskjet_5550) is a network printer (shown as /dev/null). The hp printer is currently disabled (offline), although the queue is enabled so people can continue to send jobs to the printer.

Removing print jobs with lprm

Users can remove their own print jobs from the queue with the lprm command. Used alone on the command line, lprm removes all the user's print jobs from the default printer. To remove jobs from a specific printer, use the -P option, as follows:

$ lprm -P lp0

To remove all print jobs for the current user, type the following:

$ lprm -

The root user can remove all the print jobs for a specific user by indicating that user on the lprm command line. For example, to remove all print jobs for the user named mike, the root user types the following:

# lprm –U mike

To remove an individual print job from the queue, indicate its job number on the lprm command line. To find the job number, type the lpq command. Here's what the output of that command may look like:

# lpq

printer is ready and printing

Rank Owner Job Files Total Size Time

active root 133 /home/jake/pr1 467

2 root 197 /home/jake/mydoc 23948

The output shows two printable jobs waiting in the queue. (The printer is ready and printing the job listed as active.) Under the Job column, you can see the job number associated with each document. To remove the first print job, type the following:

# lprm 133

Configuring Print Servers

You've configured a printer so that you and the other users on your computer can print to it. Now you want to share that printer with other people in your home, school, or office. Basically, that means configuring the printer as a print server.

The printers configured on your Linux system can be shared in different ways with other computers on your network. Not only can your computer act as a Linux print server (by configuring CUPS), but it can also appear as an SMB (Windows) print server to client computers. After a local printer is attached to your Linux system and your computer is connected to your local network, you can use the procedures in this section to share the printer with client computers using a Linux (UNIX) or SMB interface.

Configuring a shared CUPS printer

Making the local printer added to your Linux computer available to other computers on your network is fairly easy. If a TCP/IP network connection exists between the computers sharing the printer, you simply grant permission to all hosts, individual hosts, or users from remote hosts to access your computer's printing service.

To manually configure a printer entry in the /etc/cups/printers.conf file to accept print jobs from all other computers, make sure the Shared Yes line is set. The following example from a printers.conf entry earlier in this chapter demonstrates what the new entry would look like:

<DefaultPrinter printer>

Info HP LaserJet 2100M

Location HP LaserJet 2100M in hall closet

DeviceURI parallel:/dev/lp0

State Idle

Accepting Yes

Shared Yes

JobSheets none none

QuotaPeriod 0

PageLimit 0

KLimit 0


On Linux systems that use the Print Settings window described earlier in this chapter, it's best to set up your printer as a shared printer using that window. Here's how, using Fedora 21:

1. From the Activities screen on a GNOME 3 desktop in Fedora, type Print Settings and press Enter. The Print Settings window appears.

2. To allow all your printers to be shared, select Server arr Settings. If you are not the root user, you are prompted for the root password. The Basic Server Settings pop-up appears.

3. Select the check box next to Publish shared printers connected to this system, and click OK. You may be asked to modify your firewall to open the necessary ports for remote systems to access your printers.

4. To further allow or restrict printing for a particular printer, double-click the name of the printer you want to share. (If the printer is not yet configured, refer to the section “Setting Up Printers” earlier in this chapter.)

5. Choose the Policies heading, and select Shared so a check mark appears in the box.

6. If you want to restrict access to the printer to selected users, select the Access Control heading and choose one of the following options:

· Allow Printing for Everyone Except These Users—With this selected, all users are allowed access to the printer. By typing usernames into the Users box and clicking Add, you exclude selected users.

· Deny Printing for Everyone Except These Users—With this selected, all users are excluded from using the printer. Type usernames into the Users box and click Add to allow access to the printer for only those names you enter.

Now you can configure other computers to use your printer, as described in the section “Setting Up Printers” in this chapter. If you try to print from another computer and it doesn't work, try these troubleshooting tips:

· Open your firewall. If you have a restrictive firewall, it may not permit printing. You must enable access to TCP port 631 to allow access to printing on your computer. The Printing window may prompt you at some point to open this port. (Check the/etc/sysconfig/iptables file to see if a firewall rule is set that accepts printing from TCP port 631 or, if you are running firewalld, run firewall-config and open the ipp service.)

· Check names and addresses. Make sure you entered your computer's name and print queue properly when you configured it on the other computer. Try using the IP address instead of the hostname. (If that works, it indicates a DNS name resolution problem.) Running a tool such as tcpdump enables you to see where the transaction fails.

· Check which addresses cupsd is listening on. The cupsd daemon must be listening outside the localhost for remote systems to print to it. Use the netstat command (as the root user) as follows to check this. The first example shows cupsd only listening on local host (; the second shows cupsd listening on all network interfaces (0

# netstat -tupln | grep 631

tcp 0 0* LISTEN 6492/cupsd

# netstat -tupln | grep 631

tcp 0 0* LISTEN 6492/cupsd

Access changes to your shared printer are made in the cupsd.conf and printers.conf files in your /etc/cups directory.

Configuring a shared Samba printer

Your Linux printers can be configured as shared SMB printers so they appear to be available from Windows systems. To share your printer as if it were a Samba (SMB) printer, simply configure basic Samba server settings as described in Chapter 19, “Configuring a Windows File Sharing (Samba) Server.” All your printers should be shared on your local network by default. The next section shows what the resulting settings look like and how you might want to change them.

Understanding smb.conf for printing

When you configure Samba, the /etc/samba/smb.conf file is constructed to enable all your configured printers to be shared. Here are a few lines from the smb.conf file that relate to printer sharing:



load printers = yes

cups options = raw

; printcap name = /etc/printcap

; printing = cups



comment = All Printers

path = /var/spool/samba

browseable = yes

writeable = no

printable = yes

These example settings are the result of configuring Samba from the Samba Server Configuration window (system-config-samba) in Fedora. You can read the comment lines to learn more about the file's contents. Lines beginning with a semicolon (;) indicate the default setting for the option on a comment line. Remove the semicolon to change the setting.

The selected lines show that printers from /etc/printcap were loaded and that the CUPS service is being used. With cups options set to raw, Samba assumes that print files have already been formatted by the time they reach your print server. This allows the Linux or Windows clients to provide their own print drivers.

The last few lines are the actual printers' definition. By changing the browseable option from no to yes, users can print to all printers (printable = yes).

You can also store Windows native print drivers on your Samba server. When a Windows client uses your printer, the driver automatically becomes available. You do not need to download a driver from the vendor's website. To enable the printer driver share, add a Samba share called print$ that looks like the following:


comment = Printer Drivers

path = /var/lib/samba/drivers

browseable = yes

guest ok = no

read only = yes

write list = chris, dduffey

After you have the share available, you can start copying Windows print drivers to the/var/lib/samba/drivers directory, as described in the Samba HOWTO:

Setting up SMB clients

Chances are good that if you are configuring a Samba printer on your Linux computer, you want to share it with Windows clients. If Samba is set up properly on your computer and the client computers can reach you over the network, users should have no trouble finding and using your printer.

For many Windows systems, click Start arr Devices and Printers and select the printer from the list to configure it. In some older Windows systems, look for your shared Samba printer in Network Neighborhood (or My Network Places). From the Windows 9x desktop, double-click the Network Neighborhood icon. (From Windows 2000 or XP, double-click the My Network Places icon.)

With Windows Vista, you open the Network icon. The name of your host computer (the NetBIOS name, which is probably also your TCP/IP name) appears on the screen or within a workgroup folder on the screen. Open the icon that represents your computer. The window that opens shows your shared printers and folders.


If your computer's icon doesn't appear in Network Neighborhood or My Network Places, try using the Search window. From Windows XP, choose Start arr Search arr Computer or People arr A Computer on the Network. Type your computer's name into the Computer Name box, and click Search. Double-click your computer in the Search window results panel. A window displaying the shared printers and folders from your computer appears.

After your shared printer appears in the window, configure a pointer to that printer by opening (double-clicking) the printer icon. A message tells you that you must set up the printer before you can use it. Click Yes to proceed to configure the printer for local use. The Add Printer Wizard appears. Answer the questions that ask you how you intend to use the printer, and add the appropriate drivers. When you are finished, the printer appears in your printer window.

Another way to configure an SMB printer from a Windows XP operating system is to go to Start arr Printers and Faxes. In the Printers and Faxes window that appears, click the Add a Printer icon in the upper-left portion of the window, and select Network Printer from the first window. From there you can browse and/or configure your SMB printer.


Providing networked printing services is essential on today's business networks. With the use of a few network-attached devices, you can focus your printer spending on a few high-quality devices that multiple users can share instead of numerous lower-cost devices. In addition, a centrally located printer can make it easier to maintain the printer, while still enabling everyone to get his or her printing jobs done.

The default printing service in nearly every major Linux distribution today is the Common UNIX Printing System (CUPS). Any Linux system that includes CUPS offers the CUPS web-based administrative interface for configuring CUPS printing. It also offers configuration files in the /etc/cups directory for configuring printers and the CUPS service (cupsd daemon).

In RHEL, Fedora, Ubuntu, and other Linux systems, you can configure your printer with the printing configuration windows available in both KDE and GNOME desktops. A variety of drivers makes it possible to print to different kinds of printers, as well as to printers that are connected to computers on the network.

You can set up your computer as a Linux print server, and you can also have your computer emulate an SMB (Windows) print server. After your network is configured properly and a local printer is installed, sharing that printer over the network as a UNIX or SMB print server is not very complicated.


Use these exercises to test your knowledge of configuring printers in Linux. These tasks assume you are running a Fedora or Red Hat Enterprise Linux system (although some tasks work on other Linux systems as well). If you are stuck, solutions to the tasks are shown in Appendix B (although in Linux, you can often complete a task in multiple ways).

1. Use the Print Settings window (system-config-printer package) to add a new printer called myprinter to your system (the printer does not have to be connected to set up a print queue for the new printer). Make it a generic PostScript printer connected to a local serial, LPT, or other port.

2. Use the lpc command to see the status of all your printers.

3. Use the lpr command to print the /etc/hosts file to that printer.

4. Check the print queue for that printer to see that the print job is there.

5. Remove the print job from the queue (cancel it).

6. Using the printing window, set the basic server setting that publishes your printers so other systems on your local network can print to your printers.

7. Allow remote administration of your system from a web browser.

8. Demonstrate that you can do remote administration of your system by opening a web browser to port 631 from another system to the Linux system running your print server.

9. Use the netstat command to see which addresses the cupsd daemon is listening on (the printing port is 631).

10.Delete the myprinter printer entry from your system.