From disk to paper
Tutorial – Printing in the Shell
A few commands and some simple shell scripts make it easier to manage your printer so that you can access print functions quickly and automate recurring tasks.
If you work with LibreOffice or an image processing program like Gimp, you don't have to look too hard for the print function. The print icon is usually located in the upper left corner of the buttonbar; alternatively, you can press Ctrl+P. In many situations, however, it would be more practical to print without the help of an application – for example, if you want to print from a script.
Complex printing commands can also be transferred as shell commands. There are instructions to fit several pages on one sheet, for duplex printing, for cover sheets to make sorting easier, or for options to change the page orientation.
Linux basically comes with two commands for controlling printers at the command line, lp
and lpr
. Table 1 shows some important options, while Table 2 lists some helpful variants for everyday use. For additional options and settings, check out the extensive man pages for lp
[1] and lpr
[2].
[...]
Buy this article as PDF
(incl. VAT)