how to remove passwords from PDF in Linux

How to Remove PDF Password in Linux

PDF files are widely used due to their ease of use, portability and security features. As a part of its security features, Adobe allows you to password protect PDF documents. Sometimes you may need to remove PDF password from your document to unlock PDF. It may be because you don’t want to manually enter password every time, you want to programmatically read the contents of your PDF file. There are many Linux tools available for this purpose. In this article, we will learn how to remove PDF password in Linux.


How to Remove PDF Password in Linux

We will look at some popular Linux tools that allow you to easily remove password from PDF file and unlock PDFs.


1. Using PDF Toolkit

PDF Toolkit is a useful tool to work with PDF files. It provides many features to create, edit and share PDF files. Open terminal and run the following command to install PDF toolkit on your system.

$ sudo apt-get install pdftk

You may be asked for your user password to proceed with installation. Enter it to start installation. If you see any prompts during installation, enter y to proceed. Once it is installed, you can easily remove password from file with the following command

$ pdftk password_protected_file_path input_pw pdf_password output_file_path

In the above command, you need to enter the path to password protected filename, mention PDF password and finally the output file which will contain passwordless PDF.

For example, if you have password protected PDF at /home/ubuntu/data.pdf with password test123, you can remove its password with the following command. Here the output file new-data.pdf will not have any password.

$ pdftk /home/ubuntu/data.pdf input_pw test123 /home/ubuntu/new-data.pdf


2. Using QPDF

QPDF is another command line tool that allows you to encrypt, decrypt, merge and split PDF documents. It even allows you to remove password from PDF documents while retaining their contents. It is pre-installed in Ubuntu 14.04+. If it is not present on your system, open terminal and run the following command to install qpdf on your system.

$ sudo apt-get install qpdf

Once you have installed qpdf, you can remove password from PDF documents, using the following command.

$ qpdf --password=password --decrypt /path/to/password/protected/pdf /path/to/pdf/without/password

In the above command, you need to use –password option with qpdf command, and provide the original password of PDF document. Then you need to specify path to PDF protected PDF document, as well as the final passwordless PDF document.

For example, if you have password protected PDF at /home/ubuntu/data.pdf with password test123, you can remove its password with the following command. Here the output file new-data.pdf will not have any password.

$ qpdf --password=test123 /home/ubuntu/data.pdf /home/ubuntu/new-data.pdf

In this article, we have seen a few tools to remove PDF password in Linux. You can use them in terminal to run them on ad-hoc basis, in shell script to automatically remove password, or setup a cronjob to regularly run these commands.

Please note, although we have used PDF toolkit and QPDF to remove password from PDF documents, they also provide tons of other features that you can use to easily modify your PDF documents.

Also read:

How to Uninstall NVIDIA Drivers in Ubuntu
How to Build Deb Package in Linux
How to Rotate & Resize Images in Linux
How to Create Fillable PDF Forms in Linux
How to Limit Network Bandwidth in Linux

Leave a Reply

Your email address will not be published. Required fields are marked *