9.6. I Can't Remember Which Printer to Use
Administrators of large networks commonly have to work with a substantial number of printers. Busy offices may have several printers in a dedicated location. As an administrator, you could randomly assign one of the printers as a default for different workstations in the area. In this section, I'll present a more robust solution.
Fortunately, most Linux distributions now use CUPS to administer printers. Developed by Easy Software Products, the standard version of CUPS (http://www.cups.org) is open source and works well with the Foomatic printer driver database available from http://www.linuxprinting.org.
When you install CUPS on your system, you get access to a web-browser-based tool that can help you administer the printers on your network. If you're administering multiple printers, CUPS allows you to organize them into groups. When you print to one group, CUPS directs the print job to the first available printer in the group.
Many Linux distributions include their own printer configuration tools that work with CUPS. However, if you want to configure printers in groups, you'll want to use the CUPS command-line tools or web-based interface.
9.6.1. Installing CUPS
Installing the CUPS service and associated printer driver database is a straightforward process. It may already be installed on your system. There are a number of different CUPS packages. As different distributions configure each package differently, all I can provide are general guidelines:
These are general descriptions. For more information on packages associated with a specific distribution, use the search feature available for that distribution, such as:
9.6.2. Configuring CUPS Printers
As the process of installing a printer on CUPS is straightforward, I won't describe it in detail here. While setting up /etc/cups/cupsd.conf is a complex process, the associated configuration tools available on Red Hat/Fedora (system-config-printer), SUSE (YaST), and Debian Linux (foomatic-gui) make the procedure elementary for the Linux geek. In most cases, you can also use the web-based tool for CUPS to configure printers.
To set up a printer on CUPS, you need to know its manufacturer, model, and connection (USB, Serial, Parallel port, or network location). CUPS print tools can often detect printers shared from remote systems; otherwise, you can enter a Universal Resource Identifier (URI), which can be a URL or one of the other locations specified in Table 9-3.
9.6.3. Sharing CUPS Printers
Not all distributions support sharing of CUPS printers. If you see a cupsd-browsing.conf file in your /etc/cups directory, edit it and change the Browsing directive from off to on. Alternatively, you may need to configure sharing in the cupsd.conf <Location /> stanza. For example, if you're running CUPS on Debian Linux, the following is the default version of that stanza, which supports printing from the local computer only:
<Location /> Order Deny,Allow Deny from All Allow from 127.0.0.1 </Location>
You can expand this to the local network by specifying the associated IP addresses with a directive such as:
Allow from 192.168.0.0/255.255.255.0
Alternatively, you can support sharing via the local network cards by adding the following directive to the stanza:
Allow from @LOCAL
9.6.4. Configuring CUPS Administrators
In this section, I'll show you how to configure administrative privileges for more than just the root user. You've read about CUPS, and you know about the web-based interface. So you navigate in your browser to what you've read is the TCP/IP port associated with CUPS, 631:
You're taken to the main CUPS menu, as shown in Figure 9-1.
Figure 9-1. CUPS administrative menu
If you select the Do Administration Tasks link, you'll see a pop-up window that asks for your username and password. Some distributions preconfigure the root account to configure CUPS. If the root account does not work, or if you want to assign another user as a CUPS administrator, you need to know how to configure the main CUPS configuration file and use the lppasswd command (see "Adding CUPS administrators," later in this annoyance).
188.8.131.52. Configuring CUPS for multiple administrators
The <Location /admin> stanza defines the users and systems allowed access to CUPS administrative functions. Most distributions, including Red Hat/Fedora, SUSE, and Debian, limit access to the local computer with the following directives:
Order Deny,Allow Deny from All Allow from 127.0.0.1
If you want to configure different users as CUPS administrators, you'll need the following directives within the <Location /admin> stanza:
AuthType BasicDigest AuthClass Group
Without an AuthType directive, all users would be able to administer CUPS printers. The BasicDigest option supports basic authentication using /etc/cups/passwd.md5 as a password-verification file. While this file encrypts passwords using MD5 encryption, crackers could still decipher the password, given enough time. As with /etc/shadow, it's important to limit access to this file to the file owner (by assigning the permission 600).
The AuthClass directive defines the level of authentication. If set to User, a valid username and password are required. It's best to set it to Group, where a valid username and password are required, and the user must belong to the group defined by the AuthGroupName directive.
You'll also need an appropriate entry for the AuthGroupName directive; one commonly used group name is lpadmin. You can even make up your own group name with a directive such as:
Once you're satisfied with your <Location /admin> stanza, save your changes and restart the CUPS daemon. The name varies between distributions. You can restart CUPS with the following command on Red Hat or SUSE:
You can restart CUPS on Debian with the following command:
184.108.40.206. Adding CUPS administrators
Now you can add the users you want as CUPS administrators. The usernames and passwords don't even have to correspond to any on your system. In fact, it's an excellent idea to configure a special CUPS account so ordinary users don't play around administering your printers.
To add a CUPS administrator, use the lppasswd command. For example, if I wanted to add user nancy as an administrator, and I included the AddGroupName printadmin directive in the <Location /admin> stanza in my cupsd.conf configuration file, I'd run the following command:
lppasswd -g printadmin -a nancy
I can delete this user from the administrative database with another straightforward command:
lppasswd -g printadmin -x nancy
9.6.5. Organizing Printers by Classes
Now that you've set up administrators, you can work on the strength of CUPS, which can organize printers by groups. Presumably, you've already installed more than one printer via CUPS, which you can verify via the /etc/cups/printers.conf file.
Adding a printer class is a straightforward process. If you use the web-based tool, take the following steps: