Learn how to zip a folder in Linux using command; creating zip folder in Linux using zip command. Also learn to zip folder in Linux with password.
If zip command line tool is not installed on your system, open the terminal and write the following command to install the zip and unzip command line tools:
$ sudo apt install zip unzip
Once installed, you can run the zip command to zip a folder in Linux terminal. The sytntax of the zip command is:
$ zip -r <output_file> <folder_1> <folder_2> ... <folder_n>
For example, let’s say that you want to zip/archive a folder named “Image-Folder” in a zip file named “Image.zip”. You will run the following command:
$ zip -r Image.zip Image-Folder
Once the command is executed, the Image.zip archive will be created. To check if the zip file was created or not, run the “ls” command and search for your archive file.
$ ls -l | grep .zip
Zip folder in Linux with password
To zip folder in Linux with password, use the command option -e or –encrypt. These parameters set a password for the zip file. For example, to zip/archive a folder named “Image-Folder” in a password protected zip file named “Image.zip”. You will run the following command:
$ zip --encrypt Image.zip Image-Folder
To unzip the .zip files run the unzip command. See below:
$ sudo unzip -r Image.zip
Note: For password protected zip archive, yuo will need to enter the password to unzip.