How to decrypt PDF with just the user password from Linux bash

Encrypted PDF documents can have two passwords – owner and user. Shortly after I wrote the article “How To Remove Passwords From PDF Documents Using Linux Bash Command Line” (, ICICI Bank changed its system so that they now sent PDF documents encrypted with an owner password. pdftk was not going to work. qpdf to the rescue.

  • Install qpdf.
    sudo apt-get install qpdf
  • Create a text file at some location in your computer (with extension txt as a precautionary measure). Replace my username (comacho) with yours.
    read -p "Enter pathname of PDF for encryption: " sInputFileName
    sOutputFileName=$(basename "$sInputFileName")
    stty -echo
    read -p "Enter password to decrypt PDF: " sPassword
    stty echo
    qpdf --password=$sPassword --decrypt "$sInputFileName" "$sOutputFileName"

To decrypt PDF, just use the following command in Terminal:

sh path-to-the-txt-file

It will ask you for the pathname of the file. Copy the pathname of the file and paste it into the terminal. Next, it will ask you for the password (it will not be echoed to the screen). Then, your document will be decrypted and saved to your desktop.


Make a comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s