Linux zip and unzip explained

The zip is a technique to store multiple files together by compressing their size and also without any loss of the data. When the multiple files or directories are to be sent through the email, the good practice is to make them archived using the zip file and mailed him the attachments in the form of a compressed zip file, he can then unzip the files in their original form by unzipping them using the any unzip the package.

In this write-up, we will explore the method of zipping the multiple files or the files of large size into a compressed form and then also use the unzip command to retrieve the file in its original form.

How to install zip and unzip in the Ubuntu 22.04

The packages of the zip and unzip comes pre-installed in the new version of the Ubuntu, but if they are not installed, then you can install them using the apt package manager:

$ sudo apt install zip -y && sudo apt install unzip -y

Now will use the zip command to store and compile multiple files (you can compress the single file as well) using the zip command, for example, we will combine the different text files into a single compressed zip file, “”:

$ zip myfile.txt myfile1.txt myfile2.txt myfile3.txt

To confirm the creation of the, run the command:

$ ls -l

Similarly, we can add another text file, to the using the command:

$ zip -u file.txt

Likewise if we want to remove any file from the zip file, we can use the “-d” option:

$ zip -d myfile.txt

There are different options which can be used with the zip command whose applications are:

qThis option will not display the progress of the output of the command
mThis option will delete all the original files after zipping them
rThis option will zip the files recursively
eThis option allows you to set a password on the zip file

To find out the details of the zipped file, we will use the command:

$ zipdetails

To get more information on the zip command, we can open its manual:

$ man zip

To unzip the file, we will use the unzip command:

$ unzip

Like the zip command, we can also use different options with the unzip file:

qThis option will not show the output progress of the command
pThis option will secure the unzip file with the password
tThis option is used to display the details of the errors if the unzip command is failed to execute
vThis option is used to display the verbose details
lThis option will list the contents without extracting it

To open the manual of the unzip command in order to find out more details:

$ man unzip


We can compress the multiple files or a single large file if we want to securely transfer the files from one computer to other. In this write-up, we have explored the usage of the zip and unzip commands in the Linux distributions.