unzip password protected zip in unix

ShellUnixUnzip

Shell Problem Overview


I need to create a shell script wherein I will unzip a password protected zip file. I know the password, and need to automate the unzip process.

How can I achieve this using Unix shell scripting?

Shell Solutions


Solution 1 - Shell

unzip -P your-password zipfile.zip

man unzip

> -P password > >use password to decrypt encrypted zipfile entries (if any). THIS IS INSECURE! Many multi-user operating systems provide ways for any > user to see the current command line of any other user; even on > stand-alone systems there is always the threat of over-the-shoulder > peeking. Storing the plaintext password as part of a command line in > an automated script is even worse. Whenever possible, use the > non-echoing, interactive prompt to enter passwords. (And where > security is truly important, use strong encryption such as Pretty Good > Privacy instead of the relatively weak encryption provided by standard > zipfile utilities.)

Solution 2 - Shell

In Ubuntu, I've to install 7zip (7z) archive tool using following command:

sudo apt-get install p7zip-full

Then, you can use Ubuntu's default Archive Manager to unzip the password protected zip files

Solution 3 - Shell

I ran into problem using unzip saying need PK compat. v5.1 (can do v4.6). Installed p7zip instead and unzipped using following command:

7z x archive.zip -ppassword

Solution 4 - Shell

To unzip multiple password protected files, this command WILL NOT WORK

unzip -P PASSWORD *.zip

To make it work, you need to include the *.zip in quotes because whenever you use a wildcard (*), the shell itself will expand that and pass the results to the program. This is because, unlike most programs in UNIX, unzip cannot take more than one file at a time.

Read more here <https://chrisjean.com/unzip-multiple-files-from-linux-command-line/>;.

Therefore, to unzip multiple protected files, use this

unzip -P PASSWORD  '*.zip'    

Solution 5 - Shell

Please follow bellow instruction, i have solved same problem by following these steps.

  1. sudo apt install p7zip-full
  2. 7z x example.zip
  3. it will ask password for your zip file, provide password and let the process complete

Visit the following URL: For more details

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMurugesh AnandView Question on Stackoverflow
Solution 1 - ShellYaronView Answer on Stackoverflow
Solution 2 - ShellAtul KhanduriView Answer on Stackoverflow
Solution 3 - Shellkub1xView Answer on Stackoverflow
Solution 4 - ShellR. MogireView Answer on Stackoverflow
Solution 5 - ShellMuhammad Arsalan ToorView Answer on Stackoverflow