Controlling print jobs with shell commands
Print Center
Use shell commands to start and manage print jobs without too much clicking, while easily avoiding problems with specific file formats.
If you want to print PDF files, you would normally open them individually with a PDF viewer such as Okular or Atril and start printing from there. For starters, this takes up some of your valuable time, and there is a risk of overlooking and omitting some files. Compared to this, printing at the command line often only involves a single line of input if you are working with specific file formats, more specifically Postscript and PDF.
Printing with lpr
You can use the lp
and lpr
commands to print one or multiple files. The calls are the same for sending a print command to the default printer: lp FILE
and lpr FILE
. If you want to output the job to a specific device, you need to pass in the job name using the -d
parameter (for lp
) or -P
(for lpr
). A call via a pipe also works: echo "Hi!" | lpr
or echo "Hi!" | lp
put your output directly onto paper. You can request multiple printouts by stipulating -n NUMBER
(for lp
) or -# NUMBER
(for lpr
).
A print job for multiple files in a single command combines the pages into a single print job for both lp
and lpr
. This can cause problems in the case of printer malfunctions, for example, if the printer breaks down and pages are swallowed up due to a paper jam. Besides this, you only see the name of the last file to be printed in alphabetic order in the print job query. Although the lpq
command displays the complete queue, this can also lead to problems in practical terms if you have large-scale combined print jobs. It takes some effort to identify a file that has not been printed due to a printer error and to start a reprint. Starting the jobs individually offers you a better overview. A small for
construct (Listing 1) helps here. Figure 1 illustrates the difference between the two methods of starting print jobs.
[...]
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.
-
Valve and Arch Linux Announce Collaboration
Valve and Arch have come together for two projects that will have a serious impact on the Linux distribution.
-
Hacker Successfully Runs Linux on a CPU from the Early ‘70s
From the office of "Look what I can do," Dmitry Grinberg was able to get Linux running on a processor that was created in 1971.
-
OSI and LPI Form Strategic Alliance
With a goal of strengthening Linux and open source communities, this new alliance aims to nurture the growth of more highly skilled professionals.
-
Fedora 41 Beta Available with Some Interesting Additions
If you're a Fedora fan, you'll be excited to hear the beta version of the latest release is now available for testing and includes plenty of updates.
-
AlmaLinux Unveils New Hardware Certification Process
The AlmaLinux Hardware Certification Program run by the Certification Special Interest Group (SIG) aims to ensure seamless compatibility between AlmaLinux and a wide range of hardware configurations.
-
Wind River Introduces eLxr Pro Linux Solution
eLxr Pro offers an end-to-end Linux solution backed by expert commercial support.
-
Juno Tab 3 Launches with Ubuntu 24.04
Anyone looking for a full-blown Linux tablet need look no further. Juno has released the Tab 3.
-
New KDE Slimbook Plasma Available for Preorder
Powered by an AMD Ryzen CPU, the latest KDE Slimbook laptop is powerful enough for local AI tasks.
-
Rhino Linux Announces Latest "Quick Update"
If you prefer your Linux distribution to be of the rolling type, Rhino Linux delivers a beautiful and reliable experience.