Printing on Linux: CUPS, IPP Everywhere, and Driverless Setup

Printing on Linux: CUPS, IPP Everywhere, and Driverless Setup

Printing was the standing joke about desktop Linux for two decades. It is largely fixed, and the fix was not better drivers: it was printers that describe themselves so drivers stopped being necessary.

CUPS

CUPS is the printing system, shared with macOS. It receives jobs, converts them into a format the printer understands, manages the queue, and can serve printers to other machines.

sudo systemctl status cups
sudo systemctl enable --now cups

Its web interface is the most complete configuration tool, more so than most desktop settings panels:

http://localhost:631

Administration requires a user in the lpadmin group:

sudo usermod -aG lpadmin "$USER"     # Debian and Ubuntu
sudo usermod -aG lp,sys "$USER"      # some others

Log out and back in afterwards, since group membership is read at login.

Driverless printing

Modern network printers support IPP Everywhere, AirPrint, or Mopria. These are the same idea: the printer publishes its capabilities and CUPS uses them directly.

The practical result is that a printer on your network usually appears without any installation at all.

# What is discoverable
avahi-browse -rt _ipp._tcp
driverless

# Add one
lpadmin -p OfficePrinter -E -v ipp://printer.local/ipp/print -m everywhere

-m everywhere tells CUPS to query the printer rather than use a PPD file, which is what makes it driverless.

If nothing is discovered, check that avahi-daemon is running, since mDNS is what makes network discovery work:

sudo systemctl enable --now avahi-daemon

When you still need drivers

Older printers, very cheap models, and some vendor-specific features need a PPD or a driver package.

HP maintains HPLIP, which covers a very wide range of its printers and scanners:

sudo apt install hplip hplip-gui
sudo hp-setup -i

Brother publishes per-model .deb and .rpm packages, and its Linux support has been reliably decent for years.

Generic PostScript or PCL works for many printers when nothing better exists:

sudo apt install printer-driver-gutenprint

Gutenprint covers a large number of older inkjets and lasers with good quality output.

Managing from the command line

lpstat -p -d                  # printers and the default
lpstat -o                     # queued jobs
lp -d PrinterName file.pdf    # print
lpr -P PrinterName file.pdf
cancel -a PrinterName         # clear the queue
lpoptions -d PrinterName      # set default printer

# Options
lp -d Printer -o sides=two-sided-long-edge -o media=A4 file.pdf
lp -d Printer -o number-up=2 file.pdf

lpstat -o and cancel -a are the two worth remembering, because a stuck job blocking a queue is the most common everyday problem.

Sharing a printer

Attach a printer by USB to one machine and serve it to the rest:

sudo cupsctl --share-printers --remote-any
sudo systemctl restart cups

--remote-any allows any network; restrict it in /etc/cups/cupsd.conf if that is broader than you want:

<Location />
  Order allow,deny
  Allow 192.168.1.0/24
</Location>

Other Linux and macOS machines then discover it automatically. Open the CUPS port if a firewall is in the way:

sudo ufw allow 631/tcp

Troubleshooting

# Logs
sudo journalctl -u cups -n 50
tail -f /var/log/cups/error_log

# More detail
sudo cupsctl --debug-logging

# Is the printer reachable at all
ping printer.local
nc -zv printer.local 631

Job queued and nothing prints. Check the printer is not paused, which CUPS does automatically after an error and does not always undo:

lpstat -p
cupsenable PrinterName

Wrong page size. Set the default properly rather than per job:

lpoptions -p PrinterName -o media=A4

Prints garbage. Wrong driver, usually a PCL driver on a PostScript printer or the reverse. Try the driverless option if the printer supports it.

Scanning is separate

Printing is CUPS; scanning is SANE. A working printer says nothing about the scanner in the same device.

sudo apt install sane-utils simple-scan
scanimage -L                 # what SANE can see

For network scanners, sane-airscan provides the driverless equivalent of IPP Everywhere and covers most modern devices.

Frequently Asked Questions

Do I still need to install printer drivers on Linux?

For most printers made in the last several years, no. IPP Everywhere and AirPrint let the printer describe its own capabilities, so CUPS can drive it with no vendor software. Older and cheaper models still need a PPD or a vendor driver.

What is CUPS?

The printing system on Linux and macOS. It accepts jobs, converts documents into what the printer understands, manages queues, and exposes printers over the network. Its web interface at localhost port 631 is the most direct way to configure it.

Why does my printer appear twice?

Usually because it was discovered over both mDNS and a driver-based backend, or because both CUPS and a vendor tool added it. Remove the duplicate in the CUPS web interface and keep the driverless entry if one exists.

How do I share a printer with other machines?

Enable sharing in CUPS and allow access from your subnet, then other Linux and macOS machines will discover it automatically over mDNS. Windows clients can use the IPP URL directly.

Why does scanning not work when printing does?

They are separate subsystems. Printing goes through CUPS, scanning goes through SANE, and a driver package for one does not necessarily cover the other. Check with scanimage -L to see whether SANE detects the device at all.

Which printers are the safest choice for Linux?

Anything advertising IPP Everywhere or AirPrint, which is most current network printers from the major brands. Brother has a long record of usable Linux drivers, and HP maintains HPLIP, which covers a very wide range of its hardware.