Loading...

Lab 22: Linux Printing with CUPS

Bring printing online on a Rocky Linux host by enabling the CUPS service, validating queues, and managing print jobs from the CLI. Set a system default printer, submit and cancel a job, and identify the two configuration files that control the daemon and queues.

services packages troubleshooting

Scenario

You’ve been asked to bring printing online on a new Rocky Linux host. A queue already exists (Demo_Printer), but printing is not confirmed operational. You need to start and enable CUPS, inspect printer state, set a default destination, submit a test job, and demonstrate you can cancel stuck jobs. You also need to locate the core config files that control CUPS behavior.

Operator context

Printing incidents are usually service state, queue state (enabled/accepting), default destination, or job control. This workflow gives you a repeatable “bring it online and prove it works” checklist.

Objective

  • Start and enable the CUPS service so it persists across reboots.
  • Inspect CUPS status including queues and server settings.
  • Enable a printer queue and allow it to accept jobs.
  • Set a system default printer destination.
  • Submit a test job and verify it appears in the queue.
  • Cancel a specific job cleanly.
  • Temporarily enable remote admin/access for troubleshooting.
  • Identify core CUPS configuration files and the local admin URL.

What You’ll Practice

  • Service lifecycle management with systemctl enable --now.
  • CUPS visibility checks with lpstat and queue/job inspection with lpq.
  • Queue control using cupsenable and cupsaccept.
  • Default destination management with lpadmin -d.
  • Job submission and cancellation with lp and cancel.
  • Temporary remote admin toggles using cupsctl.
  • Locating key configuration files under /etc/cups.

Walkthrough

Step 1 : Start and enable the CUPS service.
Command
sudo systemctl enable --now cups

This is the “bring it online” action. --now starts the service immediately and enable ensures it starts after reboot.

systemctl status cups
Step 2 : Display full CUPS status in one view.
Command
lpstat -t

lpstat -t gives the “what’s configured and what’s running” view: scheduler state, default destination, and printer queue status.

# Look for:
# scheduler is running
# printer Demo_Printer is idle. enabled ...
Step 3 : Enable the queue and allow it to accept jobs.
Command
sudo cupsenable Demo_Printer && sudo cupsaccept Demo_Printer

These two states are separate. A queue can be enabled but not accepting jobs, or accepting jobs but disabled. You want both true for normal operations.

lpstat -t
Step 4 : Set the system default printer.
Command
sudo lpadmin -d Demo_Printer

Setting a default destination prevents “works for me” behavior where a user prints without specifying a queue and nothing happens because no default is defined.

lpstat -t
# Look for:
# system default destination: Demo_Printer
Step 5 : Submit a test job to the default printer.
Command
lp /etc/hosts

lp submits a job to the default destination unless you override with -d. Printing a simple local file is a fast sanity check.

# Expect a request id like:
# request id is Demo_Printer-42 (1 file(s))
Step 6 : View the job queue for a single destination.
Command
lpq -P Demo_Printer

This is your “what is stuck right now” view. It helps confirm the job exists and whether it is active/pending.

# Expect something like:
# active lab 42 hosts ...
Step 7 : Cancel a specific job cleanly.
Command
cancel Demo_Printer-42

Canceling by exact destination + job id prevents you from accidentally nuking an entire queue when you only meant to stop one job.

lpq -P Demo_Printer
Step 8 : Temporarily allow remote admin and remote access.
Safety note

Use remote access temporarily for troubleshooting and then revert. Leaving CUPS open remotely without access controls is unnecessary exposure.

Command
sudo cupsctl --remote-admin --remote-any

This flips common server-side toggles via cupsctl. Treat it as a controlled change: enable, test, then lock it back down.

lpstat -t
Step 9 : Identify core configuration files.
Paths
/etc/cups/cupsd.conf /etc/cups/printers.conf

cupsd.conf controls daemon behavior and access rules. printers.conf contains queue definitions and state.

Step 10 : Open the local CUPS web interface.
URL
http://localhost:631

Even if you manage CUPS primarily from the CLI, the web UI is the fastest way to print a test page and visually confirm queue state.

Reference

  • systemctl enable --now cups : Enables and starts the CUPS scheduler service.
  • lpstat -t : Full CUPS status summary (scheduler, default destination, printers).
  • cupsenable <queue> : Enables a printer queue.
  • cupsaccept <queue> : Allows the queue to accept jobs.
  • lpadmin -d <queue> : Sets the system default destination.
  • lp <file> : Submits a print job.
  • lpq -P <queue> : Lists jobs for a specific destination.
  • cancel <queue>-<jobid> : Cancels a specific job.
  • cupsctl --remote-admin --remote-any : Enables remote admin and remote access (use intentionally; revert when done).
  • /etc/cups/cupsd.conf : Main daemon configuration.
  • /etc/cups/printers.conf : Queue definitions and printer state.
  • http://localhost:631 : Local CUPS web interface.