Your message has been sent.
This article has been saved to your account.
Go to my account
This article has been emailed to your Kindle.
Send this article
Complete the form below to send this article, CUPS: How to Manage Multiple Printers, to a friend (or to yourself). We will never share your details (or your friend's) with anyone. For more information, read our Privacy Policy.
In this article by Ankur Shah, you will see how to manage multiple printers at a time. Unlike other printing systems, CUPS features a way to let you select a group of printers to print a job instead of selecting just one. In that way, if one printer is busy or down, another printer can be automatically selected to perform the job. Such groupings of printers are called printer classes.
Configuring Printer Classes
By default there are no printer classes set up. You will need to define them. The following are some of the criteria you can use to define printer classes:
- Printer Type: Printer type can be a PostScript or non-PostScript printer.
- Location: The location can describe the printer's place; for example the printer is placed on the third floor of the building.
- Department: Printer classes can also be defined on the basis of the department to which the printer belongs. The printer class might contain several printers that are used in a particular order.
CUPS always checks for an available printer in the order in which printers were added to a class. Therefore, if you want a high-speed printer to be accessed first, you would add the high-speed printer to the class before you add a low-speed printer. This way, the high-speed printer can handle as many print requests as possible, and the low-speed printer would be reserved as a backup printer when the high-speed printer is in use.
It is not compulsory to add printers in classes. There are a few important tasks that you need to do to manage and configure printer classes.
Printer classes can themselves be members of other classes. So it is possible for you to define printer classes for high availability for printing. Once you configure the printer class, you can print to the printer class in the same way that you print to a single printer.
Features and Advantages
Here are some of the features and advantages of printer classes in CUPS:
- Even if a printer is a member of a class, it can still be accessed directly by users if you allow it. However, you can make individual printers reject jobs while groups accept them. As the system administrator, you have control over how printers in classes can be used.
- The replacement of printers within the class can easily be done. Let's understand this with the help of an example.
You have a network consisting of seven computers running Linux, all having CUPS installed. You want to change printers assigned to the class. You can remove a printer and add a new one to the class in less than a minute. The entire configuration required is done as all other computers get their default printing routes updated in another 30 seconds. It takes less than one minute for the whole change—less time than a laser printer takes to warm up.
- A company is having the following type of printers with their policy as:
- A class for B/W laser printers that anybody can print on
- A class for draft color printers that anybody can print on, but with restrictions on volume
- A class for precision color printers that is unblocked only under the administrator's supervision
- CUPS provide the means for centralizing printers, and users will only have to look for a printer in a single place
- It provides the means for printing on another Ethernet segment without allowing normal Windows to broadcast traffic to get across and clutter up the network bandwidth
- It makes sure that the person printing from his desk on the second floor of the other building doesn't get stuck because the departmental printer on the ground floor of this building has run out of paper and his print job has got redirected to the standby printer
All of these printers hang off Windows machines, and would be available directly for other computers running under Windows. However, we get the following advantages by providing them through CUPS on a central router:
Implicit Class
CUPS also supports the special type of printer class called as implicit class. These implicit classes work just like printer classes, but they are created automatically based on the available "printers and printer classes" on the network. CUPS identifies printers with identical configurations intelligently, and has the client machines send their print jobs to the first available printer. If one or more printers go down, the jobs are automatically redirected to the servers that are running, providing fail-safe printing.
Managing Printer Classes Through Command-Line
You can perform this task only by using the lpadmin -c command. Jobs sent to a printer class are forwarded to the first available printer in the printer class.
Adding a Printer to a Class
You can run the following command with the –p and -c options to add a printer to a class:
$sudo lpadmin –p cupsprinter –c cupsclass
The above example shows that the printer cupsprinter has been added to printer class cupsclass:
You can verify whether the printers are in a printer class:
$lpstat -c cupsclass
Removing a Printer from a Class
You need to run lpadmin command with –p and –r options to remove printer from a class. If all the printers from a class are removed, then that class can get deleted automatically.
$sudo lpadmin –p cupsprinter –r cupsclass
The above example shows that the printer cupsprinter has been removed from the printer class, cupsclass:
Removing a Class
To remove a class, you can run the lpadmin command with the –x option:
$sudo lpadmin -x cupsclass
The above command will remove cupsclass.
Managing Printer Classes Through CUPS Web Interface
Like printers, and groups of printers, printer classes can also be managed by the CUPS web interface. In the web interface, CUPS displays a tab called Classes, which has all the options to manage the printer classes. You can get this tab directly by visiting the following URL: http://localhost:631/classes
If no classes are defined, then the screen will appear as follows which shows the search and sorting options:

Adding a New Printer Class
A printer class can be added using the Add Class option in the Administration tab. It is useful to have a helpful description in the Name field to identify your class. You can add the additional information regarding the printer class under the Description field that would be seen by users when they select this printer class for a job.
The Location field can be used to help you group a set of printers logically and thus help you identify different classes. In the following figure, we are adding all black and white printers into one printer class. The Members box will be pre-populated with a list of all printers that have been added to CUPS. Select the appropriate printers for your class and it will be ready for use.

Once your class is added, you can manage it using the Classes tab. Most of the options here are quite similar to the ones for managing individual printers, as CUPS treats each class as a single entity.
In the Classes tab, we can see following options with each printer class:
Stop Class
Clicking on Stop Class changes the status of all the printers in that class to "stop". When a class is stopped, this option changes to Start Class. This changes the status of all of the printers to "idle". Now, they are once again ready to receive print jobs.
Reject Jobs
Clicking on Reject Jobs changes the status of all the printers in that class to "reject jobs". When a class is in this state, this option changes to Accept Jobs which changes the status of all of the printers to "accept jobs" so that they are once again ready to accept print jobs.
Unpublished Printer
The option Unpublished Printer makes the printer unpublished and that means printer is no longer shared. The published printer option activates the printer shared mode.
The default value for any class with respect to above three options is: idle, accepting jobs, published which we can see in Class State.

Cancel All Jobs
The option Cancel All Jobs will cancel all the jobs of the class.

Delete Class
To delete a class, you can use this option. CUPS will show a warning message when a class is deleted.

Modifying a Class
To change the properties of a class, you can use the Modify Class option. Apart from changing the fields such as Location and Description, you can also add or remove printer/printers from a printer class.

Setting up Printer Options for Class
To set printer options on a printer class, you can use the Set Printer Options. There are fewer options that can be set on a class. You can set the options for "Banners" and "Policy" for the printer class.
Banners include the Starting Banner and Ending Banner (as shown in the following screenshot) for printer. If only one banner file is specified, then it will be printed before the files in the job. If a second banner file is specified, it will be printed after the files in the job.
The available banner pages depend on the local system configuration. CUPS includes the following banner files:
- none—No banner pageIt does not produce a banner page
- classified—A banner page with a classified label at the top and bottom
- Confidential—A banner page with a confidential label at the top and bottom
- secret—A banner page with a secret label at the top and bottom
- standard—A banner page with no label at the top and bottom
- topsecret—A banner page with a topsecret label at the top and bottom
- unclassified—A banner page with an unclassified label at the top and bottom
Policy includes the options such as Error Policy and Operation Policy (as shown in the following screenshot) that can be setup on the printer classes.
The Error Policy field is used to specify the error policy when there is an error in printer while printing a job. You can use options like stop-printer, retry-job, abortjobs, and so on within this option.
The Operation Policy is the field that denotes the printing policy for the printer. This policy contains information say on whether the printer is set to as default or not.

Printing a Test Page for a Printer Class
The Print Test Page option prints a test page which can be used to test the functionality of the printer class. If one of the printers is busy or down, the job is sent to another printer in the same printer class.
Setting a Printer Class as Default
The printer class can be set as the default using the option Set As Default.When you set up a printer class as the default one, you will get the following note stating that the lpoptions setting will override this default setting.

Set Allowed Users
The option Set Allowed User is used to restrict users of a printer class. This option will be very useful if someone wants to put usage control on expensive printers, limiting access to the class.
Nested Printer Classes
A printer class can also be included within another printer class, this is called as Nested Printer Class. Let's discuss this with an example. The following screenshot shows the printer class cupsclass1 which contains a printer colorprinter and a printer class cupsclass. The printer class cupsclass contains two printers cupsprinter1 and cupsprinter2.
Here one of the members of the printer class, cupsclass, is another printer classcupsclass1, this is called nesting of classes. This feature can be very useful for you as the administrator can stop individual printers from accepting jobs, forcing users to use the printer classes.

Summary
In this article, we have discussed printer classes, their configurations and usage through the command line and web-based interfaces. The advantage of having printer classes is that multiple printers can be used more efficiently (if they are in classes), which means that users can print even if one or more printers in a printer class are down.
About the Author :
Ankur Shah
Ankur Shah has been working with Linux/AIX for last 4 years as a System Administrator. His previous assignment was with Packt Publishing, where he worked as System Administrator and also started implementing CUPS. He completed his graduation in Computer Engineering from Nagpur University, India. He is currently working as a SAP Basis Administrator and also started working on Governance Risk and Compliance for access Control. He is also interested in Oracle Database Administration and Security.
He is the biggest fan of Kajol (a Bollywood actress) and dedicates this book to her. The day her movie releases is a day of celebration for him and he only parties once a year - 5th August - that's Kajol's birthday. It goes without saying that he watches all her movies several times - often dragging his friends and family to participate in his madness.
Books From Packt



Post new comment