How To Join, Split And Password Protect PDF Files From The Linux Command Line

With the Linux command line / Terminal, it is easy to merge, split and edit PDF files. There is a useful tool for that called pdftk which is like the Swiss knife for PDF-related functions.

To install pdftk, open the Linux Terminal and type in

 sudo apt install pdftk

It also has a snap available. This example uses the snap version on Ubuntu.

 sudo snap install pdftk

snap install of pdftk

Merging PDF files:

To merge different PDF files into one using pdftk, the syntax is:

 pdftk file1.pdf file2.pdf cat output newfile.pdf

In this example, different files from 1 to 6, etc are merged into a single output file named doc.pdf. This file has all the pages from the individual source files. So, the command is:

 pdftk 1.pdf 2.pdf 3.pdf 4.pdf 5.pdf 6.pdf cat output doc.pdf

joining pdf files

Another example of merging files:

example of joining pdf files

Besides merging, you can also selectively choose pages to omit or include.

Suppose you want to exclude the 4th page of the source PDF file named doc.pdf, then it can be done as follows:

 pdftk doc.pdf cat 1-3 5-end output doc_no_pg4.pdf

excluding specific pages using pdftk

This output file will have all the pages except the one excluded. Pretty cool.

Encrypting and password-protecting PDFs:

pdftk also can encrypt the source PDFs and set a password to open them. To do that, specify the encryption strength.

So, to add 128-bit encryption to a source PDF named doc.pdf, and set a password hello! to open it, the command will be:

 pdftk doc.pdf output doc_encrypted.128.pdf user_pw hello!

adding encryption and password to pdf files with pdftk

The encryption strength has to be specified after the . and the user_pw parameter for adding a password to open the file.

password for opening the pdf file

Splitting a PDF file into pages:

To split a PDF file named doc.pdf into individual pages, use the burst parameter:

 pdftk doc.pdf burst

split a pdf file using pdftk

This burst function will show the individual pages as different files.

pdf file split into different pages

Besides these basic operations, pdftk can also rotate pages, repair PDFs, and do a lot more.

To list its various functions, type in

 pdftk help

help screen for pdftk

Also, just using pdftk without any parameters or input files will list its commonly used functions.


common parameter for using pdftk

This tiny utility makes it easy to manage and edit PDF files all through a few simple commands.

All done.

  1. retro bowl says:

    Fantastic website. Plenty of helpful info here.
    I’m sending it to a few friends ans additionally sharing in delicious.
    And of course, thank you for your effort!

  2. It’s actually a nice and helpful piece of info.

    I’m happy that you just shared this helpful information with us.
    Please keep us up to date like this. Thanks for sharing.

  3. Donte says:

    Way cool! Some extremely valid points! I appreciate you penning this post
    and also the rest of the site is also really good.

  4. Please let me know if you’re looking for a article writer
    for your site. You have some really great posts and I believe
    I would be a good asset. If you ever want to take some of the load
    off, I’d really like to write some articles for your blog in exchange for a link
    back to mine. Please blast me an email if interested.

  5. Adell says:

    Everything is very open with a clear description of the challenges.
    It was truly informative. Your site is extremely helpful.
    Thank you for sharing!

  6. acheter des vues youtube says:

    Hey I know this is off topic but I was wondering if you knew of any
    widgets I could add to my blog that automatically tweet my newest twitter updates.
    I’ve been looking for a plug-in like this for quite some time and was hoping maybe you would have some experience with something like this.
    Please let me know if you run into anything. I truly enjoy reading
    your blog and I look forward to your new updates.

  7. Gina says:

    Very good article. I absolutely appreciate this website.
    Continue the good work!

  8. Launa says:

    I seriously love your site.. Great colors & theme.
    Did you make this site yourself? Please reply
    back as I’m hoping to create my own personal blog and would love to know
    where you got this from or just what the
    theme is named. Many thanks!

  9. Cara says:

    Please let me know if you’re looking for a author for your site.
    You have some really great posts and I think I would be a good asset.
    If you ever want to take some of the load off,
    I’d love to write some articles for your blog in exchange for a link back to mine.
    Please send me an email if interested. Thank you!

  10. Mei says:

    thank you for authoring this vital and important information to help us news

  11. says:

    Sorry I know it is not relevant but I just wondered if anyone
    knows what template this site is usihg as I rwally likme it