- HowTo: Create a Password Protected ZIP File in Linux
- Password Protected ZIP File in Linux
- Encrypt and Decrypt ZIP Archive in Linux
- How to Create a Password Protected ZIP File in Linux
- How to Create Password Protected ZIP in Linux
- How to Unzip Password Protected ZIP in Linux
- How to Create a Zip with Password in Linux
- Create a Zip file with Password in Linux (Using Terminal)
- Create a Password-protected zip in Linux (Using GUI)
- Can I Password Protect an existing Zip file
- How to create a password protected zip file on Linux
- How to create a password protected zip file using CLI
- How to create a password protected zip file using GUI
- Conclusion
HowTo: Create a Password Protected ZIP File in Linux
This is a small note that describes how to encrypt and decrypt a ZIP file from the Linux command line.
I’ll show how to create a password protected ZIP archive from one or several unprotected files or folders.
Warning! The standard ZIP encryption is very weak and could be cracked easily.
Password Protected ZIP File in Linux
Create an encrypted ZIP file secure.zip from some file:
$ zip --encrypt secure.zip file Enter password: Verify password: adding: file (deflated 8%)
Create password protected ZIP archive secure.zip from the several files:
$ zip --encrypt secure.zip file1 file2 file3 Enter password: Verify password: adding: file1 (stored 15%) adding: file2 (deflated 30%) adding: file3 (deflated 45%)
Create an encrypted ZIP archive secure.zip from a folder /var/log/ :
$ zip --encrypt -r secure.zip /var/log/ Enter password: Verify password: adding: var/log/ (stored 0%) adding: var/log/dmesg.0 (deflated 74%) adding: var/log/dpkg.log.9.gz (deflated 0%) adding: var/log/samba/log.asc-nb (deflated 96%) ***
Use the following command to uncompress a ZIP file:
$ unzip secure.zip Enter password: ***
Encrypt and Decrypt ZIP Archive in Linux
You were interactively prompted for the password in the examples above.
If you want to create a password protected ZIP file from some shell script, you may want to do it non-interactively.
This method is more insecure, as the password is entered as plain text.
You can easily encrypt and decrypt ZIP files from the Linux command line without being prompted for the password.
$ zip -P passw0rd secure.zip file $ zip -P passw0rd secure.zip file1 file2 file3 $ zip -P passw0rd -r secure.zip /var/log/
Uncompress a password protected ZIP archive:
$ unzip -P passw0rd secure.zip
How to Create a Password Protected ZIP File in Linux
ZIP is a very popular compression and file packaging utility for Unix-like operating systems as well as Windows. While perusing through the zip man page, I discovered some useful options for protecting zip archives.
In this post, I will show you how to create a password protected zip file on the terminal in Linux. This will help you learn a practical way of encrypting and decrypting contents of zip archive files.
First install zip utility in your Linux distribution using the package manger as shown.
$ sudo yum install zip [On CentOS/RHEL] $ sudo dnf install zip [On Fedora 22+] $ sudo apt install zip [On Debian/Ubuntu]
How to Create Password Protected ZIP in Linux
Once installed, you can use the zip command with -p flag to create a password protected zip archive called ccat-command.zip from the directory of files called ccat-1.1.0 as follows.
$ zip -p pass123 ccat-command.zip ccat-1.1.0/
However, the above method is absolutely insecure, because here the password is provided as clear-text on the command line. Secondly, it will also be stored in the history file (e.g ~.bash_history for bash), meaning another user with access to your account (more especially root user) will easily see the password.
Therefore, try to always use the -e flag, it shows a prompt allowing you to enter a hidden password as shown.
$ zip -e ccat-command.zip ccat-1.1.0/
How to Unzip Password Protected ZIP in Linux
To unzip and decrypt the content of the archive file called ccat-command.zip, use the unzip program and provide the password you entered above.
That’s It! In this post, I described how to create a password protected zip file on the terminal in Linux. If you have any queries, or other useful related tip/tricks to share, use the comment form below ping us.
How to Create a Zip with Password in Linux
A zip archive is a file format which is used to store compressed data. A zip file can store files and folders in multiple level of compressions, making it easier to archive, transport & manage a large number of files/folders.
In Linux zip files can be accessed or created using packages called zip & unzip. Both of these packages will either come pre-installed with your Linux system or you will need to fetch them from the repositories.
Here in this short tutorial I am going to show you how you can create a zip archive in Linux with password protection.
There are two ways to do it. You can either use the command line interface in Linux (often called terminal or console) OR if you are using a Desktop Environment such as Gnome, KDE, Xfce, etc, you can use GUI applications such as Ark, File Roller, and Engrampa.
Create a Zip file with Password in Linux (Using Terminal)
1. First step is to make sure that you have the correct utilities installed. If you are not already in the command-line interface (CLI), open the terminal and navigate to the location where the file that you need to add to zip archive are. You can do this easily with the cd command.
(Note: sudo is only needed if you are installing from a non-root account.)
2. Now type the following command (for Debian and Ubuntu based systems) :
sudo apt install zip unzip
For CentOS you will need to type:
sudo yum install zip unzip
And for Arch-based system, type:
3. With this done, verify that you are in the correct location and type ls in the terminal to verify that all of your files are there too.
4. Now type this is terminal.
zip -P password_here -r output_file_name.zip file1_to_add_to_archive file_2 folder_1
5. Hit enter.
The command may look confusing at first but let me explain with an example.
If I want to create a zip archive with ‘file1, file2, folder8, folder and file with space‘ in it with the password [email protected] and a file name archive.zip the command would look like this:
zip -P [email protected] -r archive.zip file1 file2 folder8 'folder and file with space'
After the command finishes executing, you can run the ls command to verify that your archive is there. To unzip the file, simply type this on your terminal:
It should now ask for the password & once you do the same, the content of the zip archive should be extracted.
Create a Password-protected zip in Linux (Using GUI)
There are many GUI programs that you can use to create zip files with passwords. But for this tutorial, I am going to use Ark. This main reason for this is the fact that Ark is Available in main repo’s of CentOS, Ubuntu, Debian, & as well as Arch Linux; Also it is very easy to use.
1. First install Ark from the app store that your Linux distribution provides. You can also use the terminal to do so, here are the commands:
For Ubuntu/Debian based Systems:
For Arch based Systems the command is:
2. After the installation is successful, open a file manager and navigate to folder where the data that you want to zip is.
3. Select the files and folders that you want to archive as a password-protected zip, right-click, click on “Compress” and select “Compress to”.
4. Enter the file name, and set the type to application/zip. After that, click on Password Protection menu and set a password for your zip file.
5. Click ok, let it process and you should now have a password-protected zip file with your stuff in it.
6. If for some reason you don’t get the right-click menu entry for Compress, here is an alternate way to do it.
7. Open Ark either from your app drawer or terminal, click on Archive on the top menu and select New.
8. Again, enter a file name, set type as application/zip and set a password using the Password Protection menu.
9. Now simply drag and drop your files into the Ark window to add them to your zip archive.
Can I Password Protect an existing Zip file
No it is not possible to add a password to an existing zip file. But what you can do instead is unzip the contents of the zip file and create a new archive with the methods above.
If you are looking for other ways to secure your data, checkout this post on how to encrypt a drive (or partition) in Linux. An encrypted drive is better than a zip because you can add more file to it later on and also access and change the content without any hassle.
How to create a password protected zip file on Linux
In the computing era, the data must be secure enough as it has to revolve around multiple machines around the globe. Password protection is the primary aspect to ensure the secure transmission of files or data.
The zip is a file format that compresses the file, and this file format serves various purposes, such as combining multiple files into a single file to make it easy to transfer.
Like most of the tasks on Linux can be carried out using CLI and GUI, similarly, a password protected zip file can also be created using both ways. This article provides the command line and graphical method to create an encrypted zip file on linux.
How to create a password protected zip file using CLI
The following steps would lead you to creating a password protected zip file on Linux.
Step 1: First open the terminal and write the following command to install the zip, and unzip command line tools (if not installed).
Step 2: The “-e and –encrypt” parameters would assist you to set a password for your zip file. For instance, the command provided below will create a zip file named linuxhint that contains two files (linux.txt and debian.txt).
Note: The command in step 2 would create a password protected zip file in the current working directory and the files contained by it also lie inside the present directory.
To include the files from other than the current directory, you have to give the complete path of the files as we did in the following command.
Note that all the files and directories from the specified target folder are added to the zip file named info.zip.
Step 3 (Optional): You can unzip the .zip files as we did in the below-mentioned command.
The output shows that the zipped file was protected, and the extraction is performed after entering the password set for that file.
Note: If in case you have entered the wrong password, you would not be able to extract files as can be seen in the following image.
How to create a password protected zip file using GUI
To create the password encrypted zip file using a graphical interface, the following steps are recommended to follow.
Step 1: Click on the “Show Applications” icon placed on the dock or press “Super Key + A” to open the applications menu.
Step 2: Search here for “Archive Manager” and click on it to open:
Step 3: Click on the three lines placed on the menu bar of the “Archive Manager” and click on “New Archive…“.
After doing so, the following box will appear, where you have to ensure the following content.
– extension must be set to “.zip”
– set a Filename, Location and Password for that zip file
At the end, click on “Create” to accomplish the process.
Step 4: Once the file is created, click on the “+” icon to add files in the zip file.
After adding files, click on the “Extract” button placed on the menu bar.
The time you click on the “Extract” button, you have to choose the extraction location. After doing so, a dialogue box will appear which requires a password for completing the extraction process as shown in the following image.
As shown in the output, the password dialogue shows that the file is now protected with some password.
Conclusion
The password protected zip file can be created using the zip and unzip command line tool. Moreover, the graphical interface of Linux can also be exercised to create a password protected zip file. This guide outlines the methods and steps that are recommended for the creation of a password protected zip file. A terminal enthusiast may prefer the CLI method over GUI as it is fast and easy to adopt. However, a novel Linux user may adopt a GUI method to do the same process.