Function to remove a password from a PDF

passpdf(){ for i; do qpdf --password=<YOUR PASSWD> --decrypt "$i" "new$i"; done; }
You should install qpdf. That way, you can have a copy without any password required.

-2
By: sputnick
2010-02-25 01:21:00

These Might Interest You

  • This command line will remove password from all PDF files in the current folder. It use qpdf.


    0
    for F in *.pdf ; do qpdf --password=your_password --decrypt "$F" "$(basename $F .pdf)-nopw.pdf" ; done
    slc66 · 2011-11-30 21:35:33 0
  • You can ask repeatedly for a non-blank password using this function: function read_password() { while [ ! -n "$USER_PASSWORD" ]; do read -s -p"Password: " USER_PASSWORD if [ ! -n "$USER_PASSWORD" ]; then echo "ERROR: You must specify a valid password, please try again" fi echo done } Also you can set a time out (in seconds) to write the password read -t 10 -s -p"Password: " USER_PASSWORD_VARIABLE if [ ! $? -eq 0 ]; then echo "Time out!" fi


    14
    read -s -p"Password: " USER_PASSWORD_VARIABLE; echo
    h3nr1x · 2011-07-20 20:22:42 0
  • You can't stand programs x, y, and z. Remove all trace of their existence by adding this function to your config. It will remove the cruft, the settings, and such and such. This function doesn't even give a damn about you trying to remove programs that don't exist: it'll just for loop to the next one on your hit list. Show Sample Output


    1
    function nuke() { if [ $(whoami) != "root" ] ; then for x in $@; do sudo apt-get autoremove --purge $x; done; else for x in $@; do apt-get autoremove --purge $x; done; fi }
    ruinbox · 2009-03-25 23:21:21 2
  • sometimes you got conflicts using SSH (host changing ip, ip now belongs to a different machine) and you need to edit the file and remove the offending line from known_hosts. this does it much easier. Show Sample Output


    -1
    function sshdel { perl -i -n -e "print unless (\$. == $1)" ~/.ssh/known_hosts; }
    xsawyerx · 2009-02-03 16:20:50 1

What Others Think

If you need to crack the password, see http://www.commandlinefu.com/commands/view/9796/find-lost-passwords-of-pdfs-files
sputnick · 341 weeks and 5 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: