Table of Contents

Working with contracts and other legal documents gets easier once you know how to digitally sign and edit PDFs. It can simply become a minor inconvenience once you know how to merge PDF files in the Linux terminal or any free graphical application. Then, you’re not stuck adding multiple PDFs to your website, annoying your readers and business partners as a result.
A lot of desktop and online options show in search engine results for “how to merge two PDF files.” Some of the most popular, reputable applications:
Problem is that none of those above are free, light-weight, private, and fitting answers for how to merge PDF files in the Linux server command line interface (CLI). Below we’ll cover:
If you don’t need cPanel, don't pay for it. Only pay for what you need with our scalable Cloud VPS Hosting.
CentOS, Debian, or Ubuntu
No Bloatware
SSH and Root Access
How to Merge PDF Files in the Linux Terminal
- First, open a Linux terminal. If working on a Linux server, log into SSH. cPanel server administrators can use cPanel Terminal or WebHost Manager (WHM) Terminal. Root access won’t matter in most cases.
- These commands are easier when you don’t have to repeatedly type full file paths from your home directory. If all or most PDF files are in the same directory, navigate to that directory with the
cd
command. - Before installing a PDF merger below, check if you already have a PDF editor installed. Type
pdf
and press Tab twice to see what programs are listed. If anything shows up, check the manual to learn what it does:
Convert ImageMagick Tool
ImageMagick is installed on all InMotion cPanel servers. Primarily for image optimization, ImageMagick includes a conversion tool that can merge PDFs: convert
. Type the program command, original PDFs in the order to be merged, then the filename for the final, merged PDF file.
You may receive the following error on a cPanel server- convert: unable to access configure file `delegates.xml' @ warning/configure.c/GetConfigureOptions/677.
If so, run convert
by itself. If that returns info about using the tool, your cPanel server administrator may have set your user to a jailed shell for better security, removing your access to the ImageMagick delegates.xml file. We recommend trying GhostScript (below) before asking for normal shell access.
To merge specific pages from PDFs, specify the pages starting from 0. For example, to merge pages 1-2 of a PDF with a second file:
Install ImageMagick on CentOS:
Install ImageMagick on Debian / Ubuntu:
Learn more about how to convert and resize files with ImageMagick.
Ghostscript
Ghostscript is installed on InMotion cPanel servers, CentOS cloud servers, and many desktop Linux distros. It is a versatile CLI app for manipulating PDF, XPS, and PostScript files. We’ll use -dNOPAUSE
to disable continuation prompts at the end of each page. The -sDEVICE
attribute designates the output device or function. You can see the full list with gs -h
command.
Install Ghostscript on CentOS:
Install Ghostscript on Debian / Ubuntu:
PDFunite
pdfunite
, by Poppler, is natively installed on Ubuntu-based Mint Cinnamon and Arch-based Manjaro. The command format is the same as the convert tool.
Install PDFunite on CentOS:
Install PDF on Debian / Ubuntu:
PDFtk (PDF Toolkit)
The PDF Toolkit has graphical and paid options. The format is a little different for PDFtk. You must add “cat output” between the original PDFs and the new PDF file.
See official documentation to install PDFtk on CentOS 6.
To install PDFtk on CentOS 7, read more about libgcj dependency issues and possible solutions from a docsplit GitHub thread.
Install PDFtk on Debian / Ubuntu:
Learn more from our Cloud Server Hosting Product Guide.