How to Encrypt / Decrypt Your PDF File in Ubuntu, Debian & Fedora Linux

Want to add password protect to your PDF files? It’s easy to do the trick in Linux in both graphical and command line ways!

By encrypting your PDF file, others need to type password to authenticate before being able to read or edit the content. It’s quite important for private information, sensitive, and/or commercial data.

Encrypt PDF via LibreOfice:

LibreOffice, the default office suite for many Linux system, has the option to add password for PDF files.

1. First, depends on your desktop environment, search for and open “LibreOffice Draw” either from your system start menu or ‘Activities’ overview.

Open LibreOffice Draw

2. When the app opens, either press ‘Ctrl + O‘ on keyboard or go to “File -> Open” to open the dialog, and finally select open your PDF file.

LibreOffice Draw Open File

3. Once the PDF is opened, you can now go to menu “File -> Export As -> Export as PDF” to open the export dialog.

LibreOffce Draw, Export as PDF menu option

4. In pop-up dialog, navigate to “Security” tab, click on ‘Set Passwords‘ button. Finally, set the open password as well as permission password (aka PDF proprietor security key) of your choice.

Tip: While open password is only for viewing the file, permission password or owner password is for printing, file copying and editing, etc.
Set open password and owner password

Single command to encrypt PDF:

For those familiar with Linux commands, there’s qpdf command to encrypt file with 256-bit encryption keys and AES.

Firstly, you may right-click on the folder that contains the PDF files, and select “Open in Terminal” option to open that folder in terminal as working directory. Then, use command:

qpdf --encrypt <user_passwd> <owner_passwd> 256 -- input.pdf output.pdf

Replace <user_passwd> and <owner_passwd> with the passwords of your choice, and done!

To use AES encryption method, simply add --use-aes=y flag, so the command will be:

qpdf --encrypt <user_passwd> <owner_passwd> 128 --use-aes=y -- input.pdf output.pdf
Most Linux has qpdf in system repository, but some don't have it pre-installed.
Debian based systems may install via sudo apt install qpdf. And Fedora can get it via sudo dnf install pdf

How to Decrypt (Remove Password) your PDF File:

If you want to remove the password protect from PDF file, so others do not need any authentication to open and use the file, use either method below.

Single command to decrypt PDF:

The qpdf also has the option to remove password from PDF file. To do so, simply run command:

qpdf --password=<PASSWORD> --decrypt encrypted.pdf decrypted.pdf
NOTE: You need to know the password before being able to decrypt PDF. And, use it to replace <PASSWORD> in command.

Use a graphical tool to decrypt PDF:

There seems no pre-installed graphical tool to do file decryption in Linux. But there are a few free open-source ones in the web. Here’s I’m going to introduce ‘unlockR’, a stupid GTK4 tool that can do the job in most Linux.

1. Firstly, follow the setup guide to install Flatpak daemon in your system:

Some Linux has Flatpak support out-of-the-box, including Fedora, Linux Mint, Pop! OS and Manjaro. For these systems, just skip the step.

2. Next, search for and open terminal from system start menu (‘Activities’ overview):

And, run command to install the unlockR as Flatpak:

flatpak install https://dl.flathub.org/repo/appstream/com.github.jkotra.unlockr.flatpakref

3. Once installed, search for and open the tool from start menu (Activities overview):

When it opens, simply click “Choose a File” button and choose your encrypted PDF, type password in next page, and finally hit Decrypt button.

(Optional) If you don’t want to use the tool any more, here’s the command to remove it from your system:

flatpak uninstall --delete-data com.github.jkotra.unlockr

That’s all. Enjoy!

Exit mobile version