Printers and printing

Printing with CUPS: the path a job takes from a command to a printer, the commands for queues and jobs, and the two command families that do the same things under different names.

Lesson 4 of 4 in objective 108. Essential system services, part of LPIC-1 Exam 102-500.

The path every job takes, and where each of the two doors sits on it. In order: lp or lpr (System V and BSD spellings of the same thing), then The queue (accept / reject decides whether it gets this far), then Filter (into something the printer understands), then Backend (cupsenable / cupsdisable decides whether it leaves), then The printer. lp or lpr System V and BSD spellings of the same thing The queue accept / reject decides whether it gets this far Filter into something the printer understands Backend cupsenable / cupsdisable decides whether it leaves The printer
The path every job takes, and where each of the two doors sits on it.

CUPS, and what happens to a job

CUPS is the printing system on essentially every Linux machine. A job submitted with lp or lpr is spooled under /var/spool/cups, filtered into a format the printer understands, and sent to the device by a backend. Printers and classes are defined in /etc/cups/printers.conf and the server itself in /etc/cups/cupsd.conf, though both are normally managed through the web interface on port 631 rather than edited.

CUPS splits its files by purpose in the ordinary way, and a backup question is really a question about that split: CONFIGURATION under /etc/cups, spooled jobs under /var/spool/cups, logs under /var/log/cups. So /etc/cups holds cupsd.conf, printers.conf and a ppd/ directory of the PostScript Printer Description files — one per queue, describing what that model can do — alongside classes.conf, client.conf and cups-files.conf. What is NOT there is error_log, which is a log, or any spool directory. Editing printers.conf by hand is discouraged because the running scheduler rewrites it; lpadmin and a reload are the supported route.

A printer has both a queue and an enabled/disabled state, and they are separate: a queue can accept jobs while the printer is stopped, so work piles up safely, and that separation is exactly what an exam question about "jobs accepted but nothing printing" is testing.

The two doors are set independently, so a printer has four states. A grid of The door in against The door out. Accepting (cupsaccept): Enabled (cupsenable) gives Jobs arrive and print; Disabled (cupsdisable) gives Work piles up safely. Rejecting (cupsreject): Enabled (cupsenable) gives Queued jobs still print; Disabled (cupsdisable) gives Nothing in, nothing out. The door out → The door in ↓ Enabled (cupsenable) Disabled (cupsdisable) Accepting (cupsaccept) Jobs arrive and print Work piles up safely Rejecting (cupsreject) Queued jobs still print Nothing in, nothing out
The two doors are set independently, so a printer has four states.

Two vocabularies for the same operations

The System V family is lp to print, lpstat to see status, and cancel to remove a job. The BSD family is lpr, lpq and lprm. CUPS implements both, so either set is a correct answer unless the question names one. lpadmin is the administrative command that adds, modifies and removes printers.

Jobs already queued belong to a destination, and moving them to another one is a scheduler operation rather than a resubmission: lpmove laser laser2 hands everything waiting on laser to laser2, and lpmove takes a single job id in place of the first queue name when only one job is meant. It needs administrative rights when the jobs belong to other users. The pairing to remember is that lpmove rescues what is already there while cupsreject or cupsdisable stops anything new arriving, so a dead printer wants both.

The two switches have two commands each, and CUPS ships both spellings of both. Whether a queue TAKES new jobs is accept and reject, which CUPS also installs as cupsaccept and cupsreject — the same programs under the names that do not collide with anything else on the system. Whether a queue SENDS what it has is cupsenable and cupsdisable. So taking a printer out of service for maintenance and having users told immediately is cupsreject laserjet: the queue refuses submissions at the door, rather than accepting work that will sit there. cupsdisable laserjet is the other choice and does the opposite — it keeps accepting and stops printing, which is what you want when the printer is coming back in an hour.

The two switches, and which one a maintenance window wants. cupsreject — Controls: The door in; A new job is: Refused, and the user is told; Use it when: The printer is going away for a while. cupsdisable — Controls: The door out; A new job is: Accepted, and it waits; Use it when: The printer is coming back shortly cupsreject cupsdisable Controls The door in The door out A new job is Refused, and the user is told Accepted, and it waits Use it when The printer is going away for a while The printer is coming back shortly
The two switches, and which one a maintenance window wants.
lpstat -p laserjetprinter laserjet is idle.  enabled since Mon 03 Aug 18:40:02cupsreject laserjetlpr -P laserjet report.pdflpr: Destination "laserjet" is not accepting jobs.told at submission, rather than piling upcupsaccept laserjet
The two switches, read and then set independently.

Worth carrying in

lp / lpr
Submit a job. System V and BSD spellings.
lpstat -t / lpq
Everything about the queues; the BSD equivalent.
cancel / lprm
Remove a job from the queue.
lpadmin
Add, modify or delete a printer.
lpmove laser laser2
Move queued jobs to another destination without asking users to resubmit.
/etc/cups/ppd/
One printer description per queue. Jobs live under /var/spool/cups, logs under /var/log/cups.
cupsreject / cupsaccept
Whether the queue takes new jobs. Spelled reject and accept too.
cupsenable / cupsdisable
Whether the queue sends the jobs it has to the printer.
/etc/cups/cupsd.conf
CUPS server configuration; the web interface is at http://localhost:631/.

What the exam does with this

Objective
108. Essential system services
Share of the exam
18.33% (the whole objective)
Questions in this lesson
10
Signed for by a person
0

Partly checked. None of the 10 questions here has been read against the cited source by a person. 10 questions have been checked against their cited clause by an automated pass — which is not the same thing, and is not a signature.

Only questions a person has signed for are used in mock exams here. That is the whole difference between the two kinds of checking above.

How these questions are written — where each question comes from, what the verification ledger records, and what happens when one is found wrong.

Drill this lesson

A lesson is one sitting: the trainer draws a short run from these questions alone and spaces the ones you get wrong.

Practise Printers and printing

Questions in this lesson

Practise Printers and printing

The rest of objective 108