Introduction to Linux Printer Management with CUPS
In this hands-on lab, you'll master printer management and configuration within a Linux environment using the CUPS (Common Unix Printing System) and the cupsd
command. This tutorial will guide you through understanding CUPS, verifying the CUPS service status, and navigating the CUPS web interface. You'll then learn to manage printers directly via the cupsd
command, including listing and adding printers. Finally, you'll delve into configuring printer settings such as setting the default printer and adjusting various printer options. This lab offers practical experience with CUPS, a critical skill for any Linux systemadmin seeking proficiency in print server management.
Understanding the CUPS Printing System in Linux
This section introduces the CUPS (Common Unix Printing System), the ubiquitous printing system for numerous Linux distributions. CUPS delivers a versatile and powerful solution for managing printers and print jobs effectively.
Let's begin by verifying the CUPS service status:
sudo systemctl status cups
Example output:
● cups.service - CUPS Printing Service
Loaded: loaded (/lib/systemd/system/cups.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2023-04-28 12:34:56 UTC; 1min 23s ago
Main PID: 1234 (cupsd)
Status: "Waiting for incoming connections"
The output confirms that the CUPS service is actively running on the system.
Next, explore the CUPS web interface, a user-friendly tool for managing printers and print tasks. Open a web browser and access http://localhost:631
. This URL leads to the CUPS web interface, enabling tasks like adding printers, managing print queues, and configuring printer settings.
Spend some time exploring the CUPS web interface to understand its features and capabilities.
Managing Printers Using the cupsd Command-Line Tool
This section focuses on managing printers using the cupsd
command, the CUPS print daemon. cupsd
provides a command-line interface for interacting directly with the CUPS printing system.
First, let's list the printers currently available on the system:
sudo cupsd -t
Example output:
scheduler is running
0 jobs in the queue
Rendering completed 0 jobs
Processed 0 jobs
Accepted 0 jobs
Rejected 0 jobs
Pending 0 jobs
Stopped 0 jobs
Canceled 0 jobs
Aborted 0 jobs
Completed 0 jobs
Purged 0 jobs
The output indicates that no printers are currently configured.
To add a new printer, use the lpadmin
command, included within the CUPS package. Let's add a printer named "MyPrinter":
sudo lpadmin -p MyPrinter -v ipp://localhost/printers/MyPrinter -P /usr/share/ppd/cupsfilters/generic.ppd -E
This command establishes a new printer named "MyPrinter" utilizing the provided URI and PPD (PostScript Printer Description) file.
To confirm the addition, list the available printers again:
sudo cupsd -t
Example output:
scheduler is running
0 jobs in the queue
Rendering completed 0 jobs
Processed 0 jobs
Accepted 0 jobs
Rejected 0 jobs
Pending 0 jobs
Stopped 0 jobs
Canceled 0 jobs
Aborted 0 jobs
Completed 0 jobs
Purged 0 jobs
1 printer
MyPrinter accepting requests since Fri 2023-04-28 12:34:56 +0000
The newly added "MyPrinter" is now visible in the printer list.
Configuring Printer Settings with cupsd in Linux
This section demonstrates how to configure various printer settings using the cupsd
command.
First, let's retrieve the current configuration of the "MyPrinter" printer:
sudo cupsd -p MyPrinter -l
Example output:
printer MyPrinter
State: idle, accepting jobs
Device URI: ipp://localhost/printers/MyPrinter
Printer is shared
Printer is located in .
Printer is connected
Printer driver: generic
Printer is enabled and ready to print
The output shows the printer is in an "idle" state and accepting print jobs.
Let's modify the printer's default paper size to A4:
sudo lpadmin -p MyPrinter -o media=a4
To confirm the change, re-examine the printer configuration:
sudo cupsd -p MyPrinter -l
Example output:
printer MyPrinter
State: idle, accepting jobs
Device URI: ipp://localhost/printers/MyPrinter
Printer is shared
Printer is located in .
Printer is connected
Printer driver: generic
Printer is enabled and ready to print
Default paper size: a4
The default paper size is now successfully set to "a4".
Next, let's pause the printer to temporarily prevent printing:
sudo cupsd -p MyPrinter -o printer-state-reasons=paused
Verify the change by checking the printer status again:
sudo cupsd -p MyPrinter -l
Example output:
printer MyPrinter
State: paused, accepting jobs
Device URI: ipp://localhost/printers/MyPrinter
Printer is shared
Printer is located in .
Printer is connected
Printer driver: generic
Printer is disabled and not ready to print
Default paper size: a4
The printer is now in a "paused" state, indicating it's unavailable for printing.
Summary: CUPS and Linux Printer Administration
This lab provided an introduction to CUPS (Common Unix Printing System), a foundational printing system used across numerous Linux distributions. You explored the CUPS web interface for printer and print job management. You also learned to leverage the cupsd
command, the CUPS print daemon, to manage printers from the command line, encompassing printer listing and addition. This hands-on experience prepares you for effective printer administration in a Linux environment.