Andrew Mercer
on this page

CUPS (Common UNIX Printing System) is the standard Linux print server, managed by lpadmin and used day to day with lpr/lpq/lpstat.

Add a printer

# Direct IP/network printer (raw or driverless IPP)
sudo lpadmin -p office-printer -E -v ipp://printer.example.com/ipp/print

# Raw TCP/socket printer (JetDirect-style, port 9100)
sudo lpadmin -p office-printer -E -v socket://192.0.2.50

# Windows/Samba shared printer
sudo lpadmin -p shared-printer -v "smb://user:password@fileserver/printer-share" -L "3rd floor" -E

# Specify a PPD/driver explicitly
sudo lpadmin -p office-printer -E -v socket://192.0.2.50 -m driver.ppd

-E enables the printer and accepts jobs. -L sets a location string shown in listings.

A "does nothing" test printer

sudo lpadmin -p bitbucket -v file:/dev/null -L "Discards everything" -E

Useful for testing that an application's print flow works without wasting paper.

Everyday commands

lpstat -p                        # list printers and their state
lpstat -a                        # which printers are accepting jobs
lpstat -a | grep -i office       # check one exists
lpr -P office-printer file.txt   # print
lpq -P office-printer            # queue
lprm -P office-printer <job-id>  # cancel a job
sudo lpadmin -x office-printer   # remove a printer

Web interface and access

CUPS has a web UI at https://localhost:631/. Key settings live in /etc/cups/cupsd.conf:

Listen localhost:631
Listen 192.168.1.10:631        # also listen on a LAN address
Browsing On
BrowseAllow @LOCAL
WebInterface Yes
<Location />
  Order allow,deny
  Allow localhost
  Allow 192.168.1.*
</Location>

Restart after edits: sudo systemctl restart cups. For USB-attached HP printers, hplip (sudo hp-setup) handles driver discovery. For most modern network printers, driverless IPP (the first example above) needs no PPD at all.