Home Command line utilities How To Merge PDF Files In Command Line On Linux
Merge PDF Files In Command Line On Linux

How To Merge PDF Files In Command Line On Linux

By sk

We already have covered how to split or extract particular pages from a PDF file in Linux using pdftk utility a while ago. That tutorial described how to extract a page range or a part of a PDF file in Linux. In this brief guide, we are going to see how to merge the two or more PDF files. It's not that difficult. Read on.

Merge PDF Files In Command Line On Linux

We can do it in two ways.

Method 1: Using pdftk

PDFtk is free graphical tool that can be used to split or merge PDF files. It is available as free and paid versions. You can use it either in CLI or GUI mode.

Let us install pdftk.

In Arch LInux and derivatives:

PDFtk is available in the AUR. You can install it using any AUR helper programs such as Yay.

$ yay -S pdftk

In Debian, Ubuntu and derivatives:

$ sudo apt-get install pdftk

On CentOS, Fedora, Red Hat:

First, Install EPEL repository:

$ sudo yum install epel-release


$ sudo dnf install epel-release

Then install PDFtk application using command:

$ sudo yum install pdftk


$ sudo dnf install pdftk

Now, let us merge some pdf files and made it a single file.

I have three pdf files namely file1.pdf, file2.pdf, file3.pdf in my current working directory. I want to merge them into a single file called outputfile.pdf. So, I ran the following command from the Terminal:

$ pdftk file1.pdf file2.pdf fiel3.pdf cat output outputfile.pdf

Alternatively, you can run:

$ pdftk *.pdf cat output outputfile.pdf

This command will merge all pdf files in the current directory into a single file.

Method 2: Using Poppler

Poppler is a PDF rendering library based on the xpdf-3.0 code base.

To install Poppler on Arch Linux based distributions, run:

$ sudo pacman -S poppler

On Debian, Ubuntu, Linux Mint:

$ sudo apt-get install poppler-utils

On RHEL, CentOS, Fedora:

$ sudo yum install poppler-utils

Once Poppler installed, run the following command to merge the pdf files in the current working directory.

$ pdfunite file1.pdf file2.pdf file3.pdf outputfile.pdf

The above command will merge file1.pdf, fiel2.pdf and file3.pdf files into a single file called outputfile.pdf.

That's it. You know now how to split a pdf file into many and how to merge many PDF files into a single file. As you can see in this guide, it is not that difficult. You can do this in couple minutes.


Thanks for stopping by!

Help us to help you:

Have a Good day!!

You May Also Like


Rizwan Mohammed December 8, 2016 - 2:54 pm

Good tips, thank you for your help.

Carlos Samey April 14, 2019 - 6:46 pm

Thank you for these instructions, really helpful!! I always use Acethinker PDF Converter to merge several PDF files into one PDF, it’s free and it works pretty well for me. Share it here as an alternative solution.

Aditya June 25, 2019 - 5:07 am

Poppler worked nicely for me. Thanks for the tip!

Leandro Gado November 5, 2019 - 1:51 am

Good tips, but the best is PDF-Shuffler, available freely in the standard repos

sk November 5, 2019 - 12:35 pm

Thanks for the heads up. I never heard about PDF-Shuffler. I will look into it soon.


Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More