Home Linux Commandline Tools 7 Useful [CLI+GUI] Tools to Remove PDF Password in Linux

7 Useful [CLI+GUI] Tools to Remove PDF Password in Linux

Are you tired of entering passwords again and again to open protected PDF files? Or, do you just want to remove the password from PDF to share an unprotected copy? In any of the above scenarios, you’re stuck in, you can quickly get out of it by decrypting your password-protected file using Linux tools and removing it forever.

Though you can also use various online sites specifically to remove passwords, it is highly not recommended as you might be sharing and storing your sensitive data on an unknown server.

So, let’s learn how to remove PDF passwords in Linux in both the command line and graphical way using the following Linux utilities:

1. PDF Toolkit (Pdftk)

pdftk is a very simple Linux utility for manipulating PDF files that also include decrypting the PDF file.

To install pdftk on Linux distros, run:

$ sudo apt install pdftk           [On Debian, Ubuntu and Mint]
$ sudo yum install pdftk           [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux]
$ sudo emerge -a app-text/pdftk    [On Gentoo Linux]
$ sudo apk add pdftk               [On Alpine Linux]
$ sudo pacman -S pdftk             [On Arch Linux]
$ sudo zypper install pdftk        [On OpenSUSE]    

To remove the PDF password using pdftk, execute the command in the below syntax:

$ pdftk <path-to-protected-filename>.pdf input_pw <yourpassword> output <path-to-newfilename>.pdf
pdftk - Remove Password from PDF File
pdftk – Remove Password from PDF File

The above command just removes the password and generates a new PDF file with the same content. You can check out for any discrepancies in a new file by opening both PDFs and comparing them side by side.

2. Qpdf

Qpdf program is also a similar utility that supports the encryption and decryption of a PDF file.

To install qpdf on Linux distros, run:

$ sudo apt install qpdf           [On Debian, Ubuntu and Mint]
$ sudo yum install qpdf           [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux]
$ sudo emerge -a app-text/qpdf    [On Gentoo Linux]
$ sudo apk add qpdf               [On Alpine Linux]
$ sudo pacman -S qpdf             [On Arch Linux]
$ sudo zypper install qpdf        [On OpenSUSE]    

Once installed, decrypt and remove a password from a PDF file using qpdf by running a command in the below syntax:

$ qpdf --decrypt <path-to-protected-filename>.pdf <path-to-newfilename>.pdf --password=<yourpassword>

The above command will create a new unencrypted file, which you can open without entering any password.

3. Ghostscript

Ghostscript is also another popular utility that helps in removing passwords from a PDF file in Linux. It’s most likely that Ghostscript will be preinstalled on your Linux system, which you can check using the:

$ ghostscript -v

If you couldn’t find it, you can install Ghostscript on Linux distros by running:

$ sudo apt install ghostscript           [On Debian, Ubuntu and Mint]
$ sudo yum install ghostscript           [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux]
$ sudo emerge -a app-text/ghostscript    [On Gentoo Linux]
$ sudo apk add ghostscript               [On Alpine Linux]
$ sudo pacman -S ghostscript             [On Arch Linux]
$ sudo zypper install ghostscript        [On OpenSUSE]    

Now, run the below script to erase the PDF password forever:

$ gs -dNOPAUSE -dBATCH -q -sDEVICE=pdfwrite -sPDFPassword=<yourpassword> -sOutputFile=<path-to-newfilename>.pdf -f <path-to-protected-filename>.pdf

Let’s get to know all parameters in detail that we passed in the above command:

  • -sDEVICE where we pass an alternate initial output device that handles saving or displaying the results in a particular format.
  • -dNOPAUSE helps in disabling the prompt and pauses at the end of each page in case another program is already “driving” Ghostscript.
  • -q option disables all logs on the screen.
  • -sPDFPassword option where we pass the original password to decrypt.
  • -dBATCH option causes Ghostscript to exit after processing all files named on the command line.

4. Poppler

Poppler is primarily a PDF processing library that contains a set of command line utilities like pdffonts for font parser, and pdfimages for image extractor for manipulating PDF documents.

Poppler also contains a separate utility called pdftops that convert PDF to PostScript (PS) and remove PDF password forever.

To install poppler on Linux distros, run:

$ sudo apt install poppler-utils      [On Debian, Ubuntu and Mint]
$ sudo yum install poppler-utils      [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux]
$ sudo emerge -a app-text/poppler     [On Gentoo Linux]
$ sudo apk add poppler-utils          [On Alpine Linux]
$ sudo pacman -S poppler-utils        [On Arch Linux]
$ sudo zypper install poppler-utils   [On OpenSUSE]    

After installation, execute the below command to decrypt a password-protected PDF file and create a new file with no password:

$ pdftops -upw <yourpassword> <path-to-protected-filename>.pdf <path-to-newfilename>.pdf

If you don’t give the path to the new unprotected file, poppler will generate a file to the Documents directory by default.

5. unlockR

If you’re not a fan of command-line applications, you don’t have to worry as GUI applications are also available to remove PDF passwords.

UnlockR is a very simple, free, and open-source graphical PDF password remover application that is available on the Flathub repository.

Next, install the unlockR package from Flathub using the command:

$ flatpak install flathub com.github.jkotra.unlockr

Now, open it from the Acitivies panel and you’ll see only one option for choosing a file. Click on it and select the protected file whose password you want to remove.

Enter the correct password and decrypt the PDF file.

unlockR - Decrypt PDF File in Linux
unlockR – Decrypt PDF File in Linux

Once you click on Decrypt, unlockR generates a new unencrypted file and saves it to the Documents directory by default.

6. Print To A File

If you don’t wish to install any other application, you can still use your default PDF viewer application and its print-to-file option to remove the password from a file.

Evince (Document Viewer)

Evince is a document viewer for the GNOME desktop environment, which is available to install from the default repositories as shown.

$ sudo apt install evince            [On Debian, Ubuntu and Mint]
$ sudo yum install evince            [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux]
$ sudo emerge -a app-text/evince     [On Gentoo Linux]
$ sudo apk add evince                [On Alpine Linux]
$ sudo pacman -S evince              [On Arch Linux]
$ sudo zypper install evince         [On OpenSUSE]    

Once installed, you’ll find the default Document viewer application, where you can open your encrypted file.

Open PDF Encrypted File
Open PDF Encrypted File

Once you opened your file in Evince, click on the top right three-line icon (hamburger icon), and inside the new pop up hit the printer icon as shown in the below screenshot.

Open Evince Printer Settings
Open Evince Printer Settings

Select the print to file option and click on the Print button. You can also change the new file location from the file input box given below.

Choose Print to File
Choose Print to File

Okular

Okular is a default application you’ll find on the KDE desktop environment, but if you want it on your Linux distribution, you can still install it from the default package manager using the command:

$ sudo apt install okular            [On Debian, Ubuntu and Mint]
$ sudo yum install okular            [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux]
$ sudo emerge -a kde-apps/okular     [On Gentoo Linux]
$ sudo apk add okular                [On Alpine Linux]
$ sudo pacman -S okular              [On Arch Linux]
$ sudo zypper install okular         [On OpenSUSE]    

Open the Okular application and click on Open Document to get the protected PDF file. Now, Use the keyboard shortcut CTRL+P or go to the File –> Print option to export your protected PDF file.

Once you’ll click on print, Okular will generate a new file with no password on the location you’ve provided in the Output file input box.

Okular Remove PDF Password in Linux
Okular Remove PDF Password in Linux

7. LibreOffice

Surprisingly, you can also use LibreOffice Draw or LibreOffice Writer to remove passwords from a PDF file in Linux. Since almost all Linux distribution ships LibreOffice by default, you don’t even have to install any other application.

The only thing you need to do is right-click on the protected PDF file and open it in LibreOffice Writer or Draw. Once you opened the file in LibreOffice, go to the File menu and Export the file directly as PDF as given in the below screenshot.

LibreOffice - Remove Password from PDF File
LibreOffice – Remove Password from PDF File
Conclusion

Locking the important PDF file with a password is now a necessary way to protect the integrity of your content, so does know the ways to decrypt it forever to avoid passing the password multiple times.

Above we learned how you can remove a password from a PDF file in Linux using various command lines and graphical applications.

Sarvottam
Sarvottam Kumar is a software engineer by profession with interest and experience in Blockchain, Angular, React and Flutter. He loves to explore the nuts and bolts of Linux and share his experience and insights of Linux and open-source on the web/various prestigious portals.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.