How to Zip and Unzip files in Linux, you must use the Command Line Interface to compress and unzip files. On Linux, there is no way to compress or unzip files.
One of the greatest ways to share many files with someone is to combine various files and directories into a single shareable file. To do this on Windows, you can use programs like WinRAR and Winzip.
However, with a Linux computer, you must use the CLI to accomplish these tasks (Command Line Interface). You won’t be able to use any apps to perform such tasks. You can compress and unzip a file on Linux using just one line of code. Do you need to zip or unzip a file on Linux but are unsure how to do so? In this tutorial, we’ll show you how to compress and unzip files in Linux.
How to Zip and Unzip Files in Linux?
You don’t need any tools to zip or Unzip a file in Linux. Just follow the steps below zip/Unzip a file:
What is Zip or Zipping a file?
Compressing a folder containing one or more files into a smaller size is known as zip or zipping a file. You may reduce the size of a folder while simultaneously protecting the files within it by zipping it. The resulting file will be in the.zip format. However, there are numerous zip file formats available, including.tar and.gz, to name a few.

How to zip files in Linux?
You can zip a file or files in Linux, using a single command. Below is the syntax of zipping files in Linux:
zip filename filea fileb filec
For instance, if you want to compress files named one, two, three to a zip file TechTwitch, write the zip command:
Example: zip TechTwitch one two three
This is a simple command that can be used to zip files. Like this, there are many commands that can zip files with the complex operation.
Zip all the files
zip -r home
This command will zip all the files and folders into the working directory.
Add files to a zip file
Now, if you want to add files to the already zipped file, you can do the same in Linux by using some changes in the zip command.
zip -r techtwitch/tech
The above command will zip all the files from the tech folder and them in the existing zip file techtwitch.
Delete a file from a zip file
You can also delete or remove a file from the zip folder without affecting it:
zip techtwitch -d technical
The above command will delete the file named technical from the zip file techtwitch without affecting the files present in it.
Copy files from one zip to other
You can also copy files from one zip folder to another without unzipping it. In Windows OS, you need to unzip it and copy it:
zip techtwitch.zip -U –out technical.zip “internet.txt”
The above command will copy the internet.txt file from the techtwitch folder to add it to the technical.zip file.
Encrypt zip file
You can also protect your zip file with a password so that if you unzip the file, it will ask for the password:
zip techtwitch.zip -r /home/wikileaks -e
Executing the above command will ask for a password two times. After that, whenever you try to unzip the techtwitch.zip file, you need to enter the correct password.
Exclude a file from zipping
Like adding all the files, you can also exclude a particular file from zipping it:
zip techtwitch.zip -r /home -x *.mp4
The above command will zip all the files in the directory folder into a zip file named techtwitch without the .mp4 file format.
That’s all about the zipping files in Linux. Read the rest of the article to unzip the files.
What is Unzip or Unzipping a file?
Unzip or Unzipping a file means that extracting or expanding the combined files or folder. Like zipping, unzipping also has different formats of files.

How to Unzip a file?
Unzipping a file is also a simple process like zipping but you need to aware of what is the format of the zipped file:
unzip techtwitch.zip
The above command will unzip the file named techtwitch. But it will throw an error if the file named techtwitch is in the .tar or .gz format
In some Linux OS, unzip is not installed by default. If it is not installed by default, install using the below commands.
sudo apt install unzip
The above code will install the unzip on your Debian. If you want to install unzip on CentOS and Fedora, type the below command:
sudo yum install unzip
Unzip .tar files
tar xvf TechTwitch.tar
The above command will unzip the file named TechTwitch.tar
Unzip .gz files
gunzip TechTwitch_tar.gz
tar xvf TechTwitch_tar
The above two commands will unzip the techtwitch.gz file without any error.
Unzip a file to another directory
You can unzip a zipped file to another folder if you want. If you unzip to another directory, you can eliminate the unwanted repetition of files.
unzip TechTwitch.zip -d /pc/computer
The above command will unzip the TechTwitch.zip file to the new directory computer.
Unzip the password-protected zip file
If your zip file is password protected, you can use the below command to enter the password to the protected zip file.
unzip -P Password TechTwitch.zip
Excluding files from unzipping
You can unzip the file by excluding a particular file.
unzip TechTwitch.zip -x computer
The above command will extract all the files from the TechTwitch.zip file except the file named computer.
Unzip multiple zipped files
You can unzip two or more zipped files in a single command.
unzip ‘*.zip’
The above command will extract all the zipped files in the directory that is in the format .zip
Wrapping Up: Zip and Unzip files in Linux
These are the commands for zipping and unzipping files on Linux computers. Unlike Windows and macOS, Linux is primarily a command-line operating system. Using the above commands, you can easily do all zipping and unzipping actions.
[…] will be applied to your file. It can also read and unpack a variety of formats, including ZIP, RAR, 7ZIP, and […]
[…] Windows, macOS, Linux […]
[…] macOS, Linux, […]
[…] the best Linux apps on your Chromebook will give you more helpful features because Linux is more stable. For example, you will notice increased speed, security, and performance. So, to […]