Print multiple files in Linux

The problem

Print many files in a single session is a common problem for people that works with big data set. Big documentation, Tax forms PDFs, lot’s of images or photos, are all data that are often stored in separated files. When you need to print them, you have to open each file with specific reader and click on print button.

The solution

A solution to this problem, is to find and install special software that give you ability to select an print some files together. But, in this article, we want to resolve this issue simply using Linux command line and default installed software.

To achieve that, we can use command lp. This command essentially

[…] submits files for printing or alters a pending job.

This means that you can use it to print only files that can be directly interpreted by CUPS printing drivers: images, pdf, plain texts. Are excluded, for example, files like .ods or .docs and similar that need a software to be correctly interpreted.

To print from command line we need, first of all, to know which printers are available for our system and how are named. To do that, we use following command:

$ lpstat -a

As result, we should receive a list like following that contains all installed printers (I highlighted printers names using bold text):


accepting requests since mer 17 ott 2012 18:27:53 CEST


accepting requests since gio 20 giu 2013 20:28:34 CEST


accepting requests since gio 04 lug 2013 13:10:17 CEST


accepting requests since gio 13 giu 2013 12:14:18 CEST


accepting requests since sab 13 apr 2013 20:24:00 CEST


accepting requests since gio 04 lug 2013 13:09:38 CEST

Now, we only need to run following command:

lp -d <printer name> <path to file>

For example, if we want to print file1.pdf (in current directory) on HP LaserJet 400, we will run:

lp -d HP_LaserJet_400_M401dne ./file1.pdf

Of course we can also use command line wildcard characters. So, for example, if we want to print all pdf files in current directory on HP LaserJet 400, we can run:

lp -d HP_LaserJet_400_M401dne ./*.pdf

As result, all pdf files will be sent to printer in alphabetical order.

Moreover, lp offers a lot of generic printing options.

For example, if you want to print more copies, you can use -n option:

lp -d HP_LaserJet_400_M401dne -n 2 ./file1.pdf

Or, if you want a twosides print, you can use following options:

  • -o sides=one-sided
  • -o sides=two-sided-long-edge
  • -o sides=two-sided-short-edge

We shown only some example of what lp can do. If you want more information, you can check official Cups documentation.


  • Cups documentation – lp