4.4. Printing and Scanning
Printing and scanning are separate subsystems with different discovery
models. CUPS accepts print jobs, stores them in queues, and sends them
through a backend to a printer or a file. SANE provides scanner access
through frontends such as scanimage and backends for USB, network, and
vendor-specific devices. Both can use DNS-SD on a local network for
driverless discovery, but CUPS and SANE do not share a queue or a discovery
database.
Figure 4.5. Conceptual print paths. A queue can use a PPD-based driver and filter, or a driverless IPP endpoint learned through DNS-SD. The backend writes to a file, a local device, or a network printer.
4.4.1. Configuring Local and Network Printers with CUPS
CUPS is a scheduler. Each printer is a queue with a device URI, a driver or
driverless protocol, default options, and an access policy. An application
submits a document to a queue through lp or lpr; CUPS filters or
converts the document, sends it to the backend, and records the job state.
The scheduler runs without a desktop, so the same commands work on a
server.
Check that the scheduler is running and list the configured destinations:
$ lpstat -r
scheduler is running
$ lpstat -p -d
printer PDF is idle. enabled since Wed Nov 18 00:06:37 2026
system default destination: PDF
The PDF queue comes from the printer-driver-cups-pdf package installed
for this chapter; it is not a physical printer but writes each job as a PDF
file. lpstat -p shows queue state and -d shows the default destination.
lpinfo -v lists the backend schemes available on this system:
$ sudo /usr/sbin/lpinfo -v
network http
network https
file cups-brf:/
network beh
serial serial:/dev/ttyS0?baud=115200
network ipp
network socket
file cups-pdf:/
network ipps
network lpd
The schemes are printed in no fixed order - two invocations on the same
machine can list them differently - and the set depends on installed
packages and local devices. ipp and ipps are the modern network
protocols, http and https carry IPP over the web transports, socket
and lpd are older raw or line-printer protocols, cups-pdf:/ is the PDF
backend, and serial addresses a serial printer.
lpstat option |
Description |
|---|---|
-r |
Report whether the CUPS scheduler is running. |
-p [queue] |
Show printer queues and their state. |
-d |
Show the default destination. |
-o [queue] |
Show queued jobs. |
-W completed -o queue |
Show completed jobs for a queue. |
-t |
Show a full status summary, including devices and defaults. |
Printer administration is restricted. On Debian the administrative group is
lpadmin, and john is deliberately not a member of it, so an attempt to
create a queue as an ordinary user is refused:
$ /usr/sbin/lpadmin -p CH04-NO -E -v cups-pdf:/ -m lsb/usr/cups-pdf/CUPS-PDF_opt.ppd
lpadmin: Printer drivers are deprecated and will stop working in a future version of CUPS.
lpadmin: Forbidden
The command exited with status 1. The deprecation message is a warning about the PPD-based driver, not the reason for the refusal; authorization is checked separately. Running the same operation with elevation creates the queue, still with the deprecation warning:
$ sudo lpadmin -p CH04-PDF -E -v cups-pdf:/ -m lsb/usr/cups-pdf/CUPS-PDF_opt.ppd
lpadmin: Printer drivers are deprecated and will stop working in a future version of CUPS.
lpadmin option |
Description |
|---|---|
-p QUEUE |
Create or modify the named queue. |
-E |
Enable the queue and accept jobs. |
-v URI |
Set the device URI or backend. |
-m MODEL |
Select a PPD model or the special value everywhere. |
-x QUEUE |
Delete the named queue. |
-d QUEUE |
Set the default destination. |
-o OPTION=VALUE |
Set a queue option, such as media size. |
-u allow:user,@group / -u deny:user,@group |
Restrict who may use the queue; group names require the @ prefix, and root is not granted access unless listed. |
The warning is significant: PPD-based drivers are legacy in CUPS 2.4 and are scheduled to stop working in a future version. A queue for a modern network printer should use IPP Everywhere instead, which Section 4.4.2 demonstrates. The queue created here exists to exercise the filter chain end to end:
$ lpstat -p CH04-PDF -l
printer CH04-PDF is idle. enabled since Wed Nov 18 13:31:08 2026
Create a small input file in the workspace - the redirection writes the file and produces no terminal output - and submit it by name:
$ printf 'Chapter 4 printer test\n' > /home/john/debian-handbook/desktop-baseline/print-test.txt
lp option |
Description |
|---|---|
-d QUEUE |
Select the destination queue. |
-t TITLE |
Set the job title shown in the queue. |
-n COPIES |
Print multiple copies. |
-o OPTION=VALUE |
Set a job option such as media=A4 or sides=two-sided-long-edge. |
-P PAGES |
Print selected pages, for example 1-3,7. |
$ lp -d CH04-PDF -t ch04-test /home/john/debian-handbook/desktop-baseline/print-test.txt
request id is CH04-PDF-65 (1 file(s))
The request ID is assigned by CUPS and differs on any other system. The
CUPS-PDF backend writes its result into the submitting user's home
directory when the job completes, and the file name records the job
number, so this run's CH04-PDF-65 request became
ch04-test__DF-job_65.pdf. If the listing does not show the file yet,
the job is still moving through the queue; the -o form of lpstat
listed above shows queued jobs until they finish:
$ ls -l /home/john/PDF
total 8
-rw------- 1 john john 4694 Nov 18 13:31 ch04-test__DF-job_65.pdf
Inspect that file to confirm the print path produced a real document with
the requested title and page size; pdfinfo comes from the
poppler-utils package, and the grep stage selects the identifying
fields:
$ pdfinfo /home/john/PDF/ch04-test__DF-job_65.pdf | grep -E '^(Title|Pages|Page size|PDF version)'
Title: (ch04-test)
Pages: 1
Page size: 595 x 842 pts (A4)
PDF version: 1.2
This proves that CUPS accepted the job, ran the filter chain, invoked the PDF backend, and wrote a one-page A4 document carrying the job title. It does not prove that a physical printer works; a hardware test would also check the device URI, the printer's page description language, duplex and tray options, and consumables.
For a local USB printer, lpinfo -v normally shows a usb:// backend, and
lpadmin is given that URI. For a network printer, use ipp:// or
ipps:// with the printer's address and resource path. The socket and
lpd backends still exist for older printers, but they send less
structured data and may need a model-specific driver; the driverless path
in the next section is preferred when the printer supports it.
4.4.2. Driverless Printing and Printer Access Controls
Driverless printing means that CUPS learns a printer's capabilities over
IPP instead of loading a model-specific PPD. The printer advertises itself
through DNS-SD with a service type such as _ipp._tcp or _ipps._tcp; a
client resolves the service, retrieves the printer's IPP attributes, and
creates a queue with -m everywhere. The queue still has a backend and a
filter chain, but the printer, not a local PPD file, describes its
supported formats and options.
The example uses ippeveprinter, a CUPS utility that advertises a virtual
IPP Everywhere printer and writes received jobs to a spool directory; the
ippfind and ippeveprinter tools are in cups-ipp-utils, and driverless
is provided by cups-filters-core-drivers. Create the spool directory in
the workspace, which is silent:
$ mkdir -p /home/john/debian-handbook/desktop-baseline/ipp-spool
Start the virtual printer in the background. The line has several stages:
nohup detaches the process from the terminal, the redirections send its
output to a log file in the workspace, the trailing & backgrounds it, and
echo $! prints the background job's process ID:
$ nohup /usr/sbin/ippeveprinter -p 8631 -d /home/john/debian-handbook/desktop-baseline/ipp-spool -k "CH04 IPP" >/home/john/debian-handbook/desktop-baseline/ippeveprinter.log 2>&1 & echo $!
428533
ippeveprinter option or argument |
Description |
|---|---|
-p PORT |
Listen on the specified TCP port. |
-d DIRECTORY |
Write received jobs to the specified spool directory. |
-k |
Keep received documents in the spool directory instead of deleting them. |
SERVICE-NAME |
Advertised service name; the positional argument (CH04 IPP here). |
The virtual printer is a local process listening on port 8631, not a physical device, but it advertises itself exactly as a network printer does. The discovery tools return two different forms of its address:
$ driverless
ipps://CH04%20IPP._ipps._tcp.local/
$ ippfind
ipp://trixie.local:8631/ipp/print
driverless prints a URI suitable for a queue; the %20 is the URL
encoding of the space in the advertised name. ippfind prints a direct IPP
endpoint with the host name and resource path. Both describe the same
service. For a queue on the same machine, the direct loopback endpoint
avoids depending on mDNS name resolution:
$ sudo lpadmin -p CH04-IPP -E -v ipp://127.0.0.1:8631/ipp/print -m everywhere
The command is silent. It creates a driverless queue whose model is the
special value everywhere, not a PPD file. Print the same test file to it:
$ lp -d CH04-IPP -t ch04-ipp /home/john/debian-handbook/desktop-baseline/print-test.txt
request id is CH04-IPP-66 (1 file(s))
The virtual printer wrote the received document to its spool directory:
$ ls -l /home/john/debian-handbook/desktop-baseline/ipp-spool
total 16
-rw-rw-r-- 1 john john 13009 Nov 18 13:31 1-ch04-ipp.urf
The .urf file is the Apple raster format used by IPP Everywhere. It is not
a PDF: the queue converted the text into the raster format that the
printer's IPP attributes advertised, without any locally installed PPD. The
number in the file name is assigned by ippeveprinter, not the CUPS request
ID.
| Queue type | What determines the output format | Advantages | Limitations |
|---|---|---|---|
| PPD-based driver | A model-specific PPD and CUPS filters | Works with many older printers and special options | Drivers are deprecated, model-specific, and can lag behind CUPS |
IPP Everywhere (-m everywhere) |
The printer's IPP attributes | No vendor PPD, automatic capability discovery, good for modern network printers | Requires a printer that advertises IPP and a reachable network path |
| Raw or socket queue | The application or a remote driver | Simple for legacy devices and print servers | No local filtering or option negotiation; the printer must understand the data |
CUPS access controls determine who may administer queues, who may print,
and whether the web interface and shared queues are exposed. cupsctl shows
the effective server settings:
$ sudo cupsctl
_debug_logging=0
_remote_admin=0
_remote_any=0
_share_printers=0
_user_cancel_any=0
BrowseLocalProtocols=dnssd
DefaultAuthType=Basic
ErrorPolicy=retry-job
IdleExitTimeout=60
JobPrivateAccess=default
JobPrivateValues=default
MaxLogSize=0
PageLogFormat=
SubscriptionPrivateAccess=default
SubscriptionPrivateValues=default
WebInterface=Yes
_share_printers=0 means the queues are not shared with other machines,
_remote_admin=0 disables remote administration, and _remote_any=0 means
remote users cannot print by default. The web interface is enabled, but the
listener configuration decides who can reach it:
$ sudo grep -E "^(Listen|Browsing|WebInterface)" /etc/cups/cupsd.conf
Listen localhost:631
Listen /run/cups/cups.sock
Browsing Yes
WebInterface Yes
Listen localhost:631 keeps the web interface and the IPP service on the
loopback address, which is also why the socket listing in Section 4.6.2
shows CUPS listening on 127.0.0.1:631 and [::1]:631. Browsing Yes
enables CUPS discovery behavior; it does not by itself publish queues to
the network. Queue administration itself is authorized by group membership
recorded in /etc/cups/cups-files.conf:
$ sudo grep -E "^SystemGroup" /etc/cups/cups-files.conf
SystemGroup root lpadmin
Adding john to lpadmin would grant queue administration; membership in
sudo gives the same power through elevation, which is what the examples
above used. Chapter 5 covers group membership
and delegation.
cupsctl form |
Effect |
|---|---|
cupsctl |
Show the current server settings. |
cupsctl --share-printers |
Allow other machines to use local queues. |
cupsctl --remote-admin |
Allow remote administration. |
cupsctl WebInterface=No |
Stop serving the web interface; set WebInterface=Yes to restore it. |
cupsctl --debug-logging |
Enable detailed logging for diagnosis. |
cupsctl -h SERVER |
Query or change another CUPS server. |
To share a queue deliberately, an administrator must do more than set one switch: the server needs a listener on an address the clients can reach, the queue must be marked shared, the firewall must permit TCP 631, and the CUPS policy must authorize the remote users. A common local-network configuration replaces the loopback listener with
Listen 0.0.0.0:631
as the content of the Listen line in /etc/cups/cupsd.conf, combined with
cupsctl --share-printers and a firewall rule limited to the trusted
network. The web interface should not be exposed to an untrusted network
without authentication and TLS, and _remote_admin=1 expands the attack
surface, so enable either only when needed and verify the policy in
/etc/cups/cupsd.conf rather than assuming the web UI shows the whole
control.
Driverless discovery depends on mDNS/DNS-SD and on the client's ability to
reach the advertised address. If driverless sees nothing while the printer
is on the same network, check that avahi-daemon is running, that UDP 5353
is not blocked between the hosts, and that the printer advertises IPP rather
than only a vendor protocol. A direct ipp:// or ipps:// URI can bypass
discovery when the address and resource path are known, but adding a queue
with -m everywhere still requires the printer to answer IPP; it does not
create driverless support for a printer that lacks it.
Remove the exercise queues when they are no longer needed. Both deletions are silent:
$ sudo lpadmin -x CH04-IPP
$ sudo lpadmin -x CH04-PDF
Stop the virtual printer by name and process ownership, which is also silent, and confirm that only the pre-existing queue remains:
$ pkill -u john ippeveprinter
$ lpstat -p
printer PDF is idle. enabled since Wed Nov 18 00:06:37 2026
The ipp-spool directory, the ippeveprinter.log file, the test file, and
the generated PDFs stay in john's home and workspace; remove them with
rm when they are no longer wanted.
4.4.3. Scanner Discovery and Troubleshooting
SANE separates scanner access into frontends and backends. scanimage is a
command-line frontend, sane-find-scanner probes the USB and SCSI buses,
and backend libraries implement specific device families or network
protocols; both tools are in sane-utils. Debian enables the backends
listed in /etc/sane.d/dll.conf and in files under /etc/sane.d/dll.d/, so
a backend that is installed but not listed is not loaded.
This guest has no scanner, so the initial discovery result is empty:
$ scanimage -L
No scanners were identified. If you were expecting something different,
check that the scanner is plugged in, turned on and detected by the
sane-find-scanner tool (if appropriate). Please read the documentation
which came with this software (README, FAQ, manpages).
sane-find-scanner looks at the buses rather than at configured backends.
Selected output; the probe's opening and closing remarks and its paragraphs
about SCSI and parallel-port devices are omitted:
$ sane-find-scanner
could not open USB device 0x1d6b/0x0001 at 001:001: Access denied (insufficient permissions)
# No USB scanners found. If you expected something different, make sure that
# you have loaded a kernel driver for your USB host controller and have setup
# the USB system correctly. See man sane-usb for details.
The device 0x1d6b/0x0001 is the Linux Foundation root hub, not a scanner.
The permission warning on the root hub is not the reason no scanner was
found; the bus simply has no scanner. On a machine with a real USB scanner,
running sane-find-scanner as root shows whether the kernel sees the
device; fix the device permissions or backend configuration afterward
rather than scanning as root.
To verify that the SANE frontend, backend loader, and image path work
without hardware, enable the test backend. The drop-in file under
dll.d contains the backend name; tee writes the root-owned file and
echoes its input to the terminal:
$ printf 'test\n' | sudo tee /etc/sane.d/dll.d/ch04-test.conf
test
List the devices again; the test backend provides two virtual devices:
$ scanimage -L
device `test:0' is a Noname frontend-tester virtual device
device `test:1' is a Noname frontend-tester virtual device
Scan one page from the first test device. -d selects the device,
--format selects the output format, --resolution sets the requested
resolution in dots per inch, and -o writes the image to a file. The
command produces no terminal output:
$ scanimage -d test --format=pnm --resolution 100 -o /home/john/debian-handbook/desktop-baseline/scan.pnm
Identify the file it wrote:
$ file /home/john/debian-handbook/desktop-baseline/scan.pnm
/home/john/debian-handbook/desktop-baseline/scan.pnm: Netpbm image data, size = 314 x 393, rawbits, greymap
The result proves that scanimage loaded a backend, negotiated a
resolution, and wrote a valid PNM image. It does not prove that a real
scanner's optics, lamp, or document feeder work. Remove the test backend
and the image; both commands are silent:
$ sudo rm -f /etc/sane.d/dll.d/ch04-test.conf
$ rm -f /home/john/debian-handbook/desktop-baseline/scan.pnm
The next scanimage -L no longer lists test:0 or test:1.
scanimage option |
Description |
|---|---|
-L |
List configured scanners. |
-d DEVICE |
Select a backend device such as test:0 or epson2:libusb:001:004. |
--format=pnm |
Write a PNM image; other formats depend on the backend. |
--resolution N |
Request a resolution in dots per inch. |
-o FILE |
Write the scan to a file. |
--batch=FORMAT |
Scan multiple pages into numbered files. |
--source NAME |
Select a document feeder or flatbed source when supported. |
Network scanners are usually discovered through DNS-SD service types such
as _uscan._tcp and _uscans._tcp (eSCL, also called AirScan) or through
a vendor backend. avahi-browse -rt _uscan._tcp lists what is advertised
and resolves each service to its host and address; -r resolves the
records and -t terminates after listing the current entries instead of
waiting for changes. That browse is the documented discovery step for a
network scanner supporting eSCL. If the scanner is visible there but not in
scanimage -L, the required SANE backend is missing: the sane-airscan
package provides eSCL and WSD support for many modern network scanners, and
vendor packages provide their own backends. Install the backend that
matches the discovery result, then rerun scanimage -L.
| Symptom | Check | Likely cause |
|---|---|---|
scanimage -L lists nothing |
sane-find-scanner, /etc/sane.d/dll.d/, lsusb |
Device absent, backend not enabled, or permissions |
| USB scanner visible but open fails | device node ownership, scanner group, udev rules |
User lacks access to the USB device |
| Scanner works as root but not as user | backend permissions and group membership | Privilege or device ACL problem |
| Network scanner not discovered | avahi-browse -rt _uscan._tcp, firewall, same subnet |
mDNS blocked or scanner not advertising |
| Scan starts but is blank | --source, --resolution, document placement |
Wrong source, feeder, or exposure settings |
| Scan is very slow | resolution, color mode, network throughput | Large image or constrained link |
| Backend reports a device busy | fuser, other scanning applications |
Another process holds the scanner |
Do not enable a real scanner's backend by guessing its name. Install a
candidate backend, run scanimage -L, and read the backend's manual page
for device-specific options. The test backend is useful for verifying the
software path, but it must not be left enabled as if it were a real device.