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:
sudo pacman -S qpdf
To remove a known password from a PDF, run:
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:
export HISTCONTROL=ignoredups:ignorespace
With ignorespace enabled, begin a command with a space to keep it out of .bash_history:
# the leading space is intentional
qpdf --password=mysecretpassword --decrypt the-secured.pdf new-unsecured.pdf