Protecting your compressed ZIP file with a password on Linux is quite straightforward. There are numerous tools available that allow you to safeguard your files with a password on a Linux system.
In this guide, we will demonstrate how to secure a ZIP file with a password using both the command line and the graphical user interface (GUI) on Ubuntu 22.04.
Requirements
- Ubuntu 22.04 Desktop installed on your system.
- A user account with sudo privileges.
Create a Password-Protected ZIP File from the Command Line
First, ensure you have the zip
and unzip
packages installed on your system. You can install them using the following command:
sudo apt-get install zip unzip -y
Create a sample file you wish to encrypt:
nano test1
Add some content:
This is my first password-protected ZIP file
Save and close the file.
Next, create a ZIP archive with a password by running the following command:
zip --encrypt test1.zip test1
You will be prompted to enter the password, as shown below:
Enter password: Verify password: adding: test1 (deflated 2%)
To unzip the password-protected file, use the following command:
unzip test1.zip
You will be required to provide the password to unzip the file:
Archive: test1.zip [test1.zip] test1 password: inflating: test1
Create a Password-Protected ZIP File from the GUI
You can also create a password-protected ZIP file using the graphical environment.
To do so, right-click on the file you wish to secure, and select Compress:
Choose the compression format, then click on Other Options. You should see the following interface:
Enter the password, click Create, and once the file is successfully compressed, you will see the newly created ZIP file:
To unzip the file, right-click on the ZIP file and select Extract Here. You will be prompted to enter the password. Provide the password and click OK to complete the extraction.
This guide has shown you how to create a password-protected ZIP file on Ubuntu 22.04 using both the command line and graphical environments.
FAQ
- Can I use this method on versions other than Ubuntu 22.04?Yes, these steps are applicable to other Ubuntu versions as long as your system has the `zip` and `unzip` utilities installed.
- Can I encrypt multiple files into one ZIP file?Yes, you can include multiple files by listing them after the
zip --encrypt
command, like so:zip --encrypt archive.zip file1 file2 file3
. - Is my data really secure with this method?While ZIP encryption provides a basic level of security, it’s recommended to use stronger encryption tools for highly sensitive data.
- What should I do if I forget the password?Unfortunately, if you forget the password used to encrypt the ZIP file, there are limited options to recover it without potentially risking your data.