~2 min read • Updated Jul 16, 2025

Linux provides a mature and flexible printing system using CUPS (Common Unix Printing System) and Ghostscript for interpreting PostScript. With these tools, users can format documents, dispatch them to printers, and manage job queues—all directly from the command line.


A Brief History of Printing


Shared Printing in the Early Days


In pre-PC environments, printers were shared over terminals. Banner pages and job tagging helped identify user prints. Output delivery was manual.


Character-Based Printers


Impact printers used fixed-width fonts. Control characters like backspace (`^H`) and underscore enabled effects such as bold and underline:


zcat /usr/share/man/man1/ls.1.gz | nroff -man | cat -A | head

Modern Printers and RIP


Laser printers support graphical output via page description languages like PostScript. Raster image processing (RIP) is now offloaded to the host system using Ghostscript, making printers cheaper and more portable.


Linux Printing Framework


CUPS handles printer drivers, spooling, and queue management. Ghostscript interprets PostScript for graphical printers. Together, they support a wide range of media types and output styles.


Preparing Files for Print


pr – Paginate Text for Monospaced Printers


Formats plain text with headers, margins, and spacing.


pr -3 -w 65 distros.txt

OptionDescription
-lPage length
-wPage width
-hCustom header title
-nLine numbering

Sending Jobs to Printers


lpr – Berkeley Style Printing


lpr -P myprinter file.txt

  • -# for copies
  • -P for target printer
  • -r removes source file after printing

lp – System V Style Printing


lp -d myprinter -o page-left=36 -o cpi=12 file.txt

OptionUsage
-o cpiCharacters per inch
-o lpiLines per inch
-o page-leftLeft margin
-o landscapeOrientation

a2ps – Convert to PostScript


Formats files into two-up layouts with headers and footers for PostScript printers.


a2ps file.txt -o output.ps -L 66

Monitoring and Managing Print Jobs


lpstat – Printer and Queue Status


lpstat -s
lpstat -a

lpq – View Queue Contents


lpq

Lists active jobs and their status, owner, size, and rank.


cancel / lprm – Cancel Print Jobs


cancel 603

Removes job #603. Use lprm or cancel depending on system style.


Conclusion


Linux offers full-featured printing utilities rooted in Unix traditions. From formatting pages with pr and dispatching with lp, to managing queues via lpq and lpstat, command-line users enjoy precise, scriptable control over print workflows—ideal for automation and system-level integration.


Written & researched by Dr. Shahin Siami