If you have a PDF document (or even a bunch of PDF documents) that are password protected, there’s a simple way to remove the password from the file in Linux. In this guide, we’ll show you how to install the qpdf tool on any Linux distro, which is a handy command line utility that can do a bunch of things to PDF documents.
The feature we’ll be covering is password removal. Keep reading to see how to remove a password from one or more PDF documents with a short and easy command.
This article isn’t about hacking PDF documents. We are assuming you already know the password to a PDF document and simply wish to remove it. You can always add a new password to the document with the same tool. We’ll show you how.
In this tutorial you will learn:
- How to install qpdf on major Linux distros
- How to remove encryption from a PDF document with qpdf
- How to password protect a PDF document
Category | Requirements, Conventions or Software Version Used |
---|---|
System | Any Linux distro |
Software | qpdf |
Other | Privileged access to your Linux system as root or via the sudo command. |
Conventions |
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command$ – requires given linux commands to be executed as a regular non-privileged user |
Install qpdf on major Linux distros
You’ll need access to the qpdf
command in order to continue. It’s probably not already installed on your Linux distro, so you can use the appropriate command below to install it with the system’s package manager.
To install qpdf on Ubuntu, Debian, and Linux Mint:
$ sudo apt install qpdf
To install qpdf on CentOS, Fedora, AlmaLinux, and Red Hat:
$ sudo dnf install qpdf
To install qpdf on Arch Linux and Manjaro:
$ sudo pacman -S qpdf
Remove password from PDF document
- Once qpdf tool is installed, run the following Linux command to remove a password from
input.pdf
PDF document and store it asoutput.pdf
.$ qpdf --password='MYPASS' --decrypt input.pdf output.pdf
- If you ever need to add the password back (or a different password), you can use the following command to do so.
$ qpdf --encrypt MYPASS MYPASS 40 -- input.pdf output.pdf
- To decrypt multiple PDF files at once, we could use the
find
command as shown below. Note that this will overwrite the encrypted file with the decrypted version. It will do this for every PDF document in your present working directory and subdirectories, but you can easily change it as needed.$ find . -name "*.pdf" -exec qpdf --password='MYPASS' --decrypt --replace-input {} \;
Closing Thoughts
In this guide, we saw how to remove a password from one or more PDF documents with a single Linux command. This is likely the easiest and most efficient way to decrypt PDF documents one at a time or in bulk. We also learned how to add password encryption to the document in case you need to put a new password on it.