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.

Concepts

  • Service lifecycle management for print scheduling using systemctl.
  • “Scheduler running” versus “queues enabled/accepting” as separate operational states.
  • Queue visibility and server status inspection with lpstat.
  • Default destination behavior (what happens when no -d is supplied).
  • Job submission, job IDs, and safe cancellation using exact identifiers.
  • Temporary remote admin toggles as an intentional troubleshooting action.

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 or pending.

# Expect something like:
# Demo_Printer is ready
# Rank  Owner  Job  File(s)      Total Size
# active lab    42  hosts        ...
Step 7 : Cancel a specific job cleanly.
Command
cancel Demo_Printer-42

Canceling by exact destination plus job id prevents you from canceling the wrong job or clearing more than you intended.

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 confirm queue state and print a test page.

Breakpoints

cups service is inactive

If lpstat -t reports the scheduler is not running, start and enable CUPS and re-check status.

queue exists but is disabled

A printer can exist but refuse work. Ensure the queue is enabled and accepting jobs before troubleshooting client behavior.

no default destination

If there is no system default destination, printing without specifying a queue can appear to “do nothing.” Set the default with lpadmin -d.

job stuck in queue

Confirm the job exists with lpq -P, then cancel by exact job id (queue-jobid) to avoid canceling the wrong work.

remote admin left enabled

If you enabled remote admin for troubleshooting, revert it when you are done to reduce exposure.

Cleanup checklist

If you enabled remote admin for troubleshooting, revert to a local-only posture and confirm the queue is healthy.

Commands
lpstat -t
lpq -P Demo_Printer
# If you changed remote-access settings, revert intentionally (site policy may differ)
sudo cupsctl --no-remote-admin --no-remote-any
Success signal

lpstat -t shows the scheduler running, the queue is enabled and accepting jobs, and the job queue is not stuck.

Reference

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