You’ve protected a PDF file containing sensitive information with a long, secure password so only the intended party can open it. However, you don’t want to enter that password every time you access the document, so you want to remove the password from your copy.

We will show you four ways in Linux to remove a password from a PDF file when you know the password.

NOTE: When we say to type something in this article and there are quotes around the text, DO NOT type the quotes, unless we specify otherwise.

Using the PDF Toolkit (pdftk)

The PDF Toolkit is a handy command line tool for manipulating PDF files. To install pdftk, press Ctrl + Alt + T to open a Terminal window. Type the following command at the prompt and press Enter.

sudo apt-get install pdftk

Type the password for your user account when prompted and press Enter.

The installation process begins with an analysis of your system and lists how many packages will be installed and how much space they will use. When asked if you want to continue, type a “y” and press Enter.

When the installation is finished type the following command at the prompt, replacing the relevant parts as indicated below.

pdftk /home/lori/Documents/secured.pdf input_pw password output /home/lori/Documents/unsecured.pdf

The breakdown of the command is as follows:

pdftk Name of the command
/home/lori/Documents/secured.pdf Full path and filename of the password-protected PDF file. Replace this with the full path and filename for your password-protected PDF file.
input_pw password Prompt for entering the user password for the protected PDF file and the password used to open the file. Replace “password” with the password used to open your file.
output /home/lori/Documents/unsecured.pdf Prompt for the path and file name you want to use for the unprotected PDF file generated by pdftk followed by the full path and filename for the unprotected PDF file that will be generated. Replace the path shown here with the full path and filename you want to use for the unprotected PDF file generated by pdftk.

Press Enter to execute the command.

The unprotected PDF file is generated and saved to the location you specified in the command.

Using QPDF

QPDF is a command-line program for Linux that converts from one PDF file to another equivalent PDF file while preserving the content of the file. The tool allows you to encrypt and decrypt, web-optimize, and split and merge PDF files.

If you’re using the latest version of Ubuntu (14.04 as of the writing of this article), QPDF is most likely installed. If it’s not installed, press Ctrl + Alt + T to open a Terminal window and type the following command at the prompt.

sudo apt-get install qpdf

Type your account password when prompted and press Enter.

Once QPDF is installed, type the following command at the prompt and press Enter.

qpdf –password=password –decrypt /home/lori/Documents/secured.pdf /home/lori/Documents/unsecured.pdf

The breakdown of the command is as follows:

qpdf Name of the command
--password=password Prompt for the password to open the protected PDF file. Enter the password for your file after the equals sign.
NOTE: There are two dashes before “password” on the left side of the equals sign.
--decrypt /home/lori/Documents/secured.pdf Prompt for the full path and filename of the PDF file from which you want to remove the password. Replace the full path and filename with one for your file.
/home/lori/Documents/unsecured.pdf Full path and filename for the unprotected PDF file that will be generated. Replace this with the full path and filename you want to use for the unprotected PDF file generated by QPDF.

Using xpdf-utils

Xpdf-utils is a package of PDF utilities that includes a PDF to PostScript converter (pdftops), a PDF document information extractor (pdfinfo), a PDF image extractor (pdfimages), a PDF to text converter (pdftotext), and a PDF font analyzer (pdffonts). For more information about each tool, type the command (in parentheses for each tool listed) followed by “–help” (two dashes before help).

To remove a password from a PDF file, we will use the PDF to PostScript (pdftops) tool and the Ghostscript PostScript-to-PDF Converter to convert the postscript file back to an unprotected PDF file.

The xpdf-utils package may already be installed if you’re using the latest version of Ubuntu. If not, type the following command at the prompt and press Enter to install the package.

sudo apt-get install xpdf-utils

Type your account password when prompted and press Enter.

Once xpdf-utils is installed, you’re ready to convert your password-protected PDF file to a postscript file. Type the following command at the prompt and press Enter.

pdftops -upw password /home/lori/Documents/secured.pdf /home/lori/Documents/unsecured.pdf

The breakdown of the command is as follows:

pdftops Name of the command
-upw password Prompt for the user password to open the protected PDF file. Replace “password” with the password that opens your protected PDF file.
NOTE: There is one dash before “upw”.
/home/lori/Documents/secured.pdf Full path and filename of the password-protected PDF file. Replace this with the full path and filename for your password-protected PDF file.
/home/lori/Documents/unsecured.pdf Full path and filename for the unprotected PDF file that will be generated. Replace this with the full path and filename you want to use for the unprotected PDF file generated by pdftops.

The postscript file is generated and placed in the folder you specified in the command.

Before converting the postscript file back to an unprotected PDF file, you must install the Ghostscript Postscript-to-PDF Converter (ps2pdf). To do this, type the following command at the prompt and press Enter.

sudo apt-get install context

Type your account password at the prompt and press Enter.

The installation process begins with an analysis of your system and lists how many packages will be installed and how much space they will use. When asked if you want to continue, type a “y” and press Enter.

Once ps2pdf is installed, type the following command at the prompt and press Enter.

ps2pdf /home/lori/Documents/unsecured.ps /home/lori/Documents/unsecured.pdf

The breakdown of the command is as follows:

ps2pdf Name of the command
/home/lori/Documents/secured.ps Full path and filename of the postscript file. Replace this with the full path and filename for your postscript file.
/home/lori/Documents/unsecured.pdf Full path and filename for the unprotected PDF file that will be generated. Replace this with the full path and filename you want to use for the unprotected PDF file generated from the postscript file by ps2pdf.

A new, unprotected PDF file is generated and placed in the folder you specified in the command.

Using Evince

Evince is the default PDF file viewer that comes with Ubuntu. You can use it to remove a password from a PDF file as long as you know the password. It’s a graphical tool, but we will run it from the command line. To run Evince, type the following command at the prompt and press Enter.

evince /home/lori/Documents/secured.pdf

Replace the full path and filename for your PDF file.

NOTE: You may see the following error message, but the file will open anyway.

Evince displays a dialog box asking for the user password to open the PDF file. Enter the password in the edit box and select how long you want Evince to remember the password. Click “Unlock Document”.

When the PDF file opens, select “Print” from the “File” menu.

On the “Print” dialog box, select “Print to File”. If you want to change the filename or the location where it’s saved, click the button next to “File” showing the path and filename.

On the “Select a filename” dialog box, navigate to the location where you want to save the unprotected PDF file and enter a name for the file in the Name field. Click “Select”.

The new path and filename displays on the “File” button. Accept the default settings for the other options and click “Print”.

The unprotected PDF file is saved to the location you chose.

Double-click on the file to open it again in Evince. Notice that you are not asked for the password.

Remember, to remove a password from a PDF file using these tools you must know the password.

Lori Kaufman Lori Kaufman
Lori Kaufman is a technology expert with 25 years of experience. She's been a senior technical writer, worked as a programmer, and has even run her own multi-location business.
Read Full Bio »

The above article may contain affiliate links, which help support How-To Geek.