LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

Printing

Getting Started

Printing on Linux goes through CUPS, which provides two command families: System V style (lp, lpstat, cancel) and BSD style (lpr, lpq, lprm). Both talk to the same print system; use whichever you prefer. CUPS also has a web interface at http://localhost:631.

List Printers

Show available printers, the default printer, and full status.
$ lpstat -p -d
copy
$ lpstat -t
copy
Set the default printer.
$ lpoptions -d [printerName]
copy

Print a file

Print to the default printer, or pick one explicitly: lp uses -d (destination), lpr uses -P.
$ lp [file]
copy
$ lp -d [printerName] [file]
copy
$ lpr [file]
copy
$ lpr -P [printerName] [file]
copy
Anything can be piped to the printer, and pr paginates plain text nicely first.
$ echo "Hello" | lp
copy
$ pr -l60 [file] | lpr
copy

Print Options

-n sets the number of copies; -o passes printer options.
$ lp -n 3 [file]
copy
$ lp -o sides=two-sided-long-edge [file]
copy
$ lp -o page-ranges=1-4,7 [file]
copy
$ lp -o landscape -o fit-to-page [image.png]
copy
OptionDescription
sides=two-sided-long-edgeDuplex printing (long edge binding)
page-ranges=1-4,7Print only these pages
number-up=2Multiple pages per sheet
landscapeRotate output 90 degrees
fit-to-pageScale to fit the paper

Cancel Print Jobs

Cancel a specific job by ID (shown by lpq or lpstat -o), your most recent job, or everything.
$ cancel [jobID]
copy
$ cancel -a [printerName]
copy
$ lprm [jobID]
copy
$ lprm -
copy
lprm - removes all of your own jobs. Cancelling other users' jobs requires root.

Manage Printers

Stop and start a printer's output, for example to clear a paper jam without losing queued jobs.
$ cupsdisable [printerName]
copy
$ cupsenable [printerName]
copy
Add a printer or list available drivers and connections with CUPS admin tools (root required).
$ lpinfo -v
copy
$ lpadmin -p [printerName] -E -v ipp://[host]/ipp/print -m everywhere
copy
Most modern network printers support driverless printing (IPP Everywhere), which is what -m everywhere sets up.
Copied to clipboard
Kai