Skip to content

Remove PDF password in Linux

Remove a known password from a PDF on Linux with QPDF.

1 min read

Using QPDF

QPDF is a command-line tool that transforms PDF files while preserving their content. It can encrypt, decrypt, web-optimize, split, and merge PDFs.

On Omarchy, QPDF should already be installed. If it isn't, install it with:

Shell command
sudo pacman -S qpdf

To remove a known password from a PDF, run:

Shell command
qpdf --password=mysecretpassword --decrypt the-secured.pdf new-unsecured.pdf

Keep the command out of Bash history

Set this variable before running the QPDF command, or add it to .bashrc and open a new terminal:

.bashrc
export HISTCONTROL=ignoredups:ignorespace

With ignorespace enabled, begin a command with a space to keep it out of .bash_history:

Shell command
# the leading space is intentional
qpdf --password=mysecretpassword --decrypt the-secured.pdf new-unsecured.pdf

Reference

More posts connected by shared tags.