Menu
Manage printers and printing
“Add local and network printers to CUPS, manage print queues with lp and the old lpr commands, and fix the usual printing problems.”
Printing feels old-fashioned until the office printer stops working and you’re the “Linux person”. On Linux, almost all printing goes through CUPS, and once you know how its queues work, most printing problems take a minute to find: a queue that’s paused, a printer that’s offline, or a driver that sends gibberish.
This objective is about the basics: set up a local or network printer, manage the jobs in a queue with both the CUPS and the old LPD commands, and troubleshoot.
How CUPS works#
CUPS (once short for Common UNIX Printing System) is a print server. Its daemon, cupsd, runs on every machine that prints:
- You send a file to a queue (a named printer) with
lporlpr. - cupsd stores the job in the spool directory,
/var/spool/cups/. - Filters convert the file (PDF, text, an image) into something the printer understands.
- A backend sends the result to the device: USB, the network, or another print server.
cupsd speaks IPP (Internet Printing Protocol), which runs over HTTP on port 631. That’s also where its web interface lives: open http://localhost:631/ in a browser on the machine to add printers and manage jobs.
Modern network printers support IPP Everywhere (driverless printing): CUPS asks the printer what it can do, so you don’t need a driver. Older printers use a PPD file (PostScript Printer Description) that describes the printer’s options. PPD drivers still work but are deprecated.Michael Sweet started CUPS in 1997. macOS has used it since 2002 and Apple bought it in 2007, which is why your Mac prints the same way. Today the OpenPrinting project leads its development.
Try it in a container#
You can practise without a printer. Install CUPS in a Debian container, start the daemon, and create a queue that prints to /dev/null:
docker run -it --rm debian
apt update && apt install -y cups cups-bsd
cupsd # starts in the background
lpadmin -p office -E -v file:///dev/null -m raw
lpadmin -d officelpadmin: Raw queues are deprecated and will stop working in a future version of CUPS.
The warning is fine for a test queue. On a real machine CUPS runs as a service: sudo systemctl enable --now cups (the unit is cups.service on Debian, Ubuntu, RHEL and Fedora). On Debian and Ubuntu, cups-bsd adds the legacy lpr, lpq and lprm commands. On RHEL and Fedora they come with cups-client.
Adding and removing printers with lpadmin#
lpadmin creates, changes and deletes queues. It needs root, or membership in the CUPS admin group (lpadmin on Debian and Ubuntu, wheel or sys on RHEL).
First, see what CUPS can find:
sudo lpinfo -v # devices and backends: usb://, ipp://, socket://...
lpinfo -m | head # available drivers (models)network socket
network ipp
network lpd
direct usb://HP/LaserJet%20Pro%20M404?serial=PHB1234567
network ipps://Brother%20HL-L2350DW._ipps._tcp.local/
Then add the queue:
# A network printer with IPP Everywhere (no driver needed)
sudo lpadmin -p office -E -v ipp://192.168.1.50/ipp/print -m everywhere \
-L "2nd floor" -D "Office laser"
# An old printer on raw port 9100 (JetDirect), with a PPD file
sudo lpadmin -p lab -E -v socket://192.168.1.60:9100 -P /root/lab-printer.ppd
# A queue on another CUPS server
sudo lpadmin -p hq -E -v ipp://printsrv.example.com:631/printers/office -m everywhere| Option | Meaning |
|---|---|
-p name | The queue to create or change |
-E | Enable it and accept jobs (only after -p; before it, -E means “use encryption”) |
-v URI | Device URI: ipp://, ipps://, socket://, lpd://, usb://, smb:// |
-m model | Driver: everywhere, raw, or a name from lpinfo -m |
-P file.ppd | Use this PPD file |
-L, -D | Location and description text |
-d name | Make it the system default printer |
-x name | Delete the queue |
-o printer-is-shared=true | Share this queue with the network |
Remove a printer:
sudo lpadmin -x labRemote printers and sharing#
There are two ways to print through another machine’s CUPS server:
- Add a local queue pointing at the remote queue, like
hqabove (ipp://server:631/printers/name). - Skip local queues and send everything to that server: set
ServerName printsrv.example.comin/etc/cups/client.conf, or theCUPS_SERVERvariable.
On the server side, allow sharing and remote access with cupsctl, which edits cupsd.conf for you and restarts cupsd:
sudo cupsctl --share-printers # publish shared queues
sudo cupsctl --remote-any # accept connections from any network
sudo cupsctl --remote-admin # allow admin pages from other machines
sudo lpadmin -p office -o printer-is-shared=trueOn clients, the cups-browsed service finds shared printers on the network and adds them automatically.
CUPS configuration files#
Everything lives in /etc/cups/:
| File | Holds |
|---|---|
cupsd.conf | The scheduler’s settings: Listen, Browsing, LogLevel, and <Location> blocks that say who may do what |
cups-files.conf | File paths, the admin group (SystemGroup), log size |
printers.conf | The queues. Written by cupsd: stop cupsd before editing it by hand, or use lpadmin |
classes.conf | Printer classes: groups of printers that share one queue |
ppd/ | One PPD file per queue |
client.conf | Client settings, like ServerName |
lpoptions | System-wide default printer and options (users have ~/.cups/lpoptions) |
cups-browsed.conf | Settings for finding network printers |
A trimmed cupsd.conf:
LogLevel warn
Listen localhost:631
Listen /run/cups/cups.sock
Browsing On
DefaultAuthType Basic
<Location />
Order allow,deny
Allow @LOCAL
</Location>
<Location /admin>
Order allow,deny
</Location>Logs go to /var/log/cups/: error_log (problems), access_log (requests) and page_log (pages printed). Restart cupsd after editing cupsd.conf by hand: sudo systemctl restart cups.
Printing and managing jobs#
CUPS has two families of commands. The System V style (lp, lpstat, cancel) is the CUPS native one. The BSD / LPD style (lpr, lpq, lprm) comes from the old Berkeley line printer daemon. CUPS implements both, and the exam asks about both.
| Task | CUPS / System V | Legacy LPD (BSD) |
|---|---|---|
| Print a file | lp -d office file | lpr -P office file |
| Print 2 copies | lp -n 2 file | lpr -# 2 file |
| Show the queue | lpstat -o office | lpq -P office |
| Remove a job | cancel 12 | lprm 12 |
| Remove all your jobs | cancel -u $USER | lprm - |
| Printer status | lpstat -p | lpc status |
Print something:
echo "Hello printer" > note.txt
lp note.txt # to the default printer
lp -d office -n 2 -o sides=two-sided-long-edge note.txt
lpr -P office note.txtrequest id is office-1 (1 file(s))
request id is office-2 (1 file(s))
lpr prints nothing on success. Job IDs are queue-number for lp and just the number for the LPD tools.
Look at the queue:
lpq -P office
lpq -a # all queues
lpstat -o # all jobs, CUPS styleoffice is ready and printing
Rank Owner Job File(s) Total Size
active amin 2 note.txt 1024 bytes
1st amin 3 note.txt 1024 bytes
Remove jobs:
lprm 3 # one job (LPD style)
lprm - # all of your jobs (as root: all jobs)
cancel office-2 # CUPS style
cancel -a office # every job in the office queue
sudo lpmove office-4 lab # move a waiting job to another queueUsers only cancel their own jobs. Root can cancel anyone’s.
Defaults#
lpstat -d # show the default printer
sudo lpadmin -d office # system-wide default
lpoptions -d office # your personal default, saved in ~/.cups/lpoptionsThe PRINTER (or LPDEST) variable overrides the default for one shell.
Troubleshooting printing#
Start with the big picture, then narrow down:
lpstat -tscheduler is running
system default destination: office
device for office: ipp://192.168.1.50/ipp/print
office accepting requests since Tue 01 Dec 2026 02:50:11 PM CET
printer office disabled since Tue 01 Dec 2026 03:02:40 PM CET -
Unable to connect to printer; will retry in 30 seconds.
office-5 amin 1024 Tue 01 Dec 2026 03:02:39 PM CET
lpstat -t combines -r (scheduler), -d (default), -v (device URIs), -a (accepting), -p (printer state) and -o (jobs). Here the queue accepts jobs, but the printer is disabled because it can’t be reached.
A queue has two separate switches, and mixing them up is a classic exam trap:
| Switch | On | Off | When off |
|---|---|---|---|
| Printing | cupsenable office | cupsdisable office | Jobs are accepted and wait in the queue |
| Accepting jobs | cupsaccept office | cupsreject -r "Toner change" office | New jobs are refused with that reason |
So the usual checklist is:
- Is cupsd running?
systemctl status cups, orlpstat -r. - Is the queue enabled and accepting?
lpstat -p -a. Fix withcupsenableandcupsaccept. - Can you reach the printer?
ping 192.168.1.50, check the URI withlpstat -v, and make sure port 631 (IPP) or 9100 (socket) isn’t blocked by a firewall. - What does the log say?
sudo tail -f /var/log/cups/error_log. For more detail,sudo cupsctl --debug-logging, print again, thensudo cupsctl --no-debug-logging. - Pages full of garbage symbols? The driver is wrong. Re-add the queue with
-m everywhereor the right PPD. - Stuck jobs? Clear them with
cancel -a office, thencupsenable office. - “Forbidden” in the web interface? Your user isn’t in the admin group, or
cupsd.confdoesn’t allow your address.
Exam checklist#
- CUPS =
cupsd, IPP on port 631, web interface athttp://localhost:631/, config in/etc/cups/. cupsd.confconfigures the daemon.printers.conflists the queues and is written by cupsd. PPDs live in/etc/cups/ppd/.lpadmin -p name -E -v URI -m modeladds a printer,-xremoves it,-dsets the default.lpinfo -vand-mlist devices and drivers.- Legacy LPD commands:
lpr -P printerprints,lpqlists,lprm job(orlprm -) removes. - CUPS commands:
lp -d,lpstat(-tshows everything),cancel,lpmove,lpoptions -d. cupsenable/cupsdisablecontrol printing.cupsaccept/cupsrejectcontrol whether jobs are accepted.- Remote printers use URIs like
ipp://host/ipp/printorsocket://host:9100. Useclient.confServerNameto print through another CUPS server. - Logs are in
/var/log/cups/error_log, jobs are spooled in/var/spool/cups/.
Answer these 3 questions to commit this byte to your learning path.
Reset. This byte isn't committed any more. Answer the questions again to commit it.
$ git commit -m "learn(lpic-108): Manage printers and printing"
[main dfe7942] learn(lpic-108): Manage printers and printing
1 byte changed, 3 insertions(+)
See it on your path Already committed . Try the questions again any time, it won't undo anything. To uncommit it and start over: