108.4 Manage printers and

Tech Tutorial: 108.4 Manage printers and printing jobs #

Introduction #

In the realm of Linux system administration, managing printers and their respective print jobs is a critical skill. This tutorial will focus on utilizing the Common UNIX Printing System (CUPS) along with the legacy Line Printer Daemon (LPD) compatibility interface to handle print queues and user print jobs effectively. Understanding these tools will enable you to configure and manage printers on a Linux system efficiently.

Key Knowledge Areas: #

  • Managing printers with CUPS
  • Handling print queues
  • Cancelling and reordering print jobs
  • LPD compatibility interface

Utilities: #

  • lpadmin
  • lpstat
  • lp
  • lprm
  • lpq
  • lpc

Step-by-Step Guide #

1. Managing Printers with CUPS #

1.1 Adding a Printer #

To add a printer using the lpadmin command, you need to specify the printer name, connection protocol, and device URI. Here’s a basic example of adding a network printer:

lpadmin -p Printer_Name -E -v socket://192.168.1.5:9100

In this command:

  • -p specifies the printer name.
  • -E enables the printer and accepts jobs.
  • -v defines the device URI.

1.2 Removing a Printer #

To remove a printer, use lpadmin with the -x option:

lpadmin -x Printer_Name

2. Managing Print Queues and Jobs #

2.1 Checking Printer Status #

The lpstat command is used to get the status of printers and print jobs. To check the status of all printers:

lpstat -p

2.2 Printing a File #

To print a document, use the lp command:

lp -d Printer_Name document.txt
  • -d specifies the printer name.

2.3 Cancelling a Print Job #

To cancel a print job, first find the job ID using lpstat, then use lprm:

lpstat -o
lprm Job_ID

3. LPD Compatibility Interface #

3.1 Using lpq to View Queue #

The lpq command checks the content of the print queue:

lpq -P Printer_Name

3.2 Using lpc for Control #

The lpc command provides limited control over printer spools. To check the status of a printer:

lpc status Printer_Name

Detailed Code Examples #

Example: Adding Multiple Printers #

lpadmin -p Office_Printer -E -v ipp://office-printer.local
lpadmin -p HR_Printer -E -v dnssd://HR-Printer._ipp._tcp.local

Example: Printing Multiple Files #

lp -d Office_Printer report.pdf
lp -d HR_Printer memo.docx

Example: Managing Print Jobs #

lpstat -t  # Shows all printers and jobs
lprm -P HR_Printer 1023  # Cancel job ID 1023 on HR_Printer

Example: Checking and Clearing Queues #

lpq -P Office_Printer
lpc stop Office_Printer
lpc start Office_Printer

Conclusion #

In this tutorial, we covered the essential aspects of managing printers and print jobs on Linux using CUPS and the LPD compatibility interface. By mastering these commands, you can effectively manage printing operations within a Linux environment, ensuring smooth and efficient handling of print resources. Whether adding new printers, managing queues, or cancelling jobs, these tools provide the control necessary for comprehensive print management.

Remember, consistent practice and exploration of these commands in different scenarios will deepen your understanding and proficiency in managing Linux-based printing services.