Why Merge PDFs via the Terminal?
While there are dozens of graphical PDF editors available for Linux, combining multiple PDF files into a single document is often faster and more efficient using the command line. Graphical tools can sometimes alter formatting, compress images aggressively, or simply take too long to open for a quick task. By utilizing the pdfunite tool—which is part of the Poppler PDF rendering library commonly pre-installed on Ubuntu—you can instantly merge any number of PDF files directly from the Terminal without opening a heavy graphical interface.
Step 1: Verify Poppler Utilities is Installed
The pdfunite command is part of the poppler-utils package. While it is usually included by default on modern Ubuntu desktop installations, it is best to verify it is installed before proceeding.
- Open your Terminal application (Ctrl + Alt + T).
- Type the following command and press Enter:
sudo apt install poppler-utils - If it is already installed, the system will tell you it is on the newest version. If not, it will install the necessary components.
Step 2: Using the pdfunite Command
The syntax for pdfunite is very straightforward. You simply list the input files in the exact order you want them to appear, followed by the name of the final output file.
- In the Terminal, navigate to the directory where your PDF files are located using the
cdcommand. For example:cd ~/Documents/Reports - Type
pdfunitefollowed by a space. - Type the name of the first file, a space, the name of the second file, and so on.
- Finally, type the name you want to give the newly created merged file. For example:
pdfunite cover.pdf chapter1.pdf chapter2.pdf final_report.pdf- Press Enter.
Helpful Tips for Bulk Merging
If you have dozens of PDF files to merge and typing them all out is impractical, you can use a wildcard (*). However, be aware that the wildcard will merge the files in alphabetical order.
- To merge all PDFs in the current directory alphabetically into a file called “merged.pdf”, use this command:
pdfunite *.pdf merged.pdf
The tool works silently; if the command executes without returning any errors, your new final_report.pdf or merged.pdf file will instantly appear in the directory, completely intact and perfectly merged.