I have a password protected PDF file. I know the password but in order to share the file, I have to remove the password from the PDF and share an unprotected copy. How can I do this in Ubuntu with or without the GUI?


The easiest way GUI (recommended for novice)

Open the protected file and use ctrl+p or use print option to print the file, now save the file as pdf.

Using Command line

If you have pdftk already installed you can skip step1

Step 0: To check if Pdftk is already installed

sudo apt list | grep pdftk 

If output contains '[installed]' tag with pdftk then you can skip step1 i.e if the output is like this

pdftk/xenial 2.02-4 amd64 [installed]

Step 1: Install pdftk

sudo apt-get install pdftk

Step 2: Run following command

pdftk /path/to/input.pdf input_pw <yourpassword> output out.pdf

If you don't want to install pdftk there is another utility qpdf which is automatically installed (at least on 16.04 which I am using)

To use qpdf for generating unsecured pdf run following command.

qpdf -password=<your-password> -decrypt /path/to/secured.pdf out.pdf

For detailed information take a look at this HTG tutorial

  • 1
    Thanks it works for me. – Vikash Singh May 9 '19 at 6:00

I tried this in ubuntu mate 19.04:

sudo apt-get install qpdf
qpdf --password=YOURPASSWORD-HERE --decrypt input.pdf output.pdf


  • 2
    Awesome! pdftk didn't work for me due to encryption (InvalidPdfException: unknown.encrpytion.type.r), but qpdf did! – Christian Benke Apr 27 '20 at 19:59
sudo apt-get install pdftk
pdftk input.pdf output output.pdf user_pw YOURPASSWORD-HERE

This takes your input.pdf, removes the passwords and exports it as output.pdf.

You may want to take a look here to explore additional mehods.

  • This didn't work for me – ptetteh227 Jan 21 '18 at 10:09
  • Didn't work for me either. This works by putting the user_pw param just after input.pdf (it seems params are positional). So "pdftk input.pdf user_pw YOURPASSWORD-HERE output output.pdf " should work (I've used input_pw instead of user_pw). – Bozzy Feb 12 at 11:57

Rising the topic from the dead a little bit here (but I am a new Linux user, so...);

  1. Anyhow, I also used the file for which I had known the password. But I used "Master PDF Editor 5" (unregistered, free version) to remove the password (File - Properties - Security - No Encription).
  2. However, since "Master PDF Editor 5" leaves the watermark (which I personally, do not mind), I re-opened (the now unlocked file) in Libre Office Draw and removed the watermark.
  3. I exported the file in PDF, which additionally resulted in tremendous compression without any losses. It was a very simple file; one sheet only, with text in the table, but the above process reduced the size from 70-ish KB to 22-ish KB.

Use this zsh function:

pdf-unencrypt () {
    : "Usage: <file>
Uses ghostscript to rewrite the file without encryption."
    local in="$1"
    gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile="${in:r}_unencrypted.pdf" -c .setpdfwrite -f "$in"

: is a no-operations function. $in:r gets the variable without its extension. You obviously need ghostscript installed.

Not the answer you're looking for? Browse other questions tagged or ask your own question.