How to Zip and Unzip Files in Linux (Guide)
File compression is a strong mechanism to avoid wasting cupboard space and facilitate simple file transfers, particularly when the file dimension is large. There are numerous codecs of compressed recordsdata comparable to .zip, .rar, and so forth. However, zip stays essentially the most generally used format. Should you’re on a Linux system, zipping and unzipping … The post How to Zip and Unzip Files in Linux (Guide) appeared first on Ferdja.

File compression is a strong mechanism to avoid wasting cupboard space and facilitate simple file transfers, particularly when the file dimension is large. There are numerous codecs of compressed recordsdata comparable to .zip, .rar, and so forth. However, zip stays essentially the most generally used format. Should you’re on a Linux system, zipping and unzipping recordsdata (compressing and decompressing) is a activity that you may accomplish from the command line interface in addition to the GUI. So, on this article, we’ve mentioned methods to zip and unzip recordsdata in Linux utilizing these two strategies.
For these unaware, zipping means compressing a file or a number of recordsdata of various codecs right into a single file, such that it occupies much less area and could be transferred utilizing much less bandwidth. Unzipping a file means extracting all of the compressed recordsdata from a zipper file. That mentioned, let’s take a look at how one can zip and unzip recordsdata in Linux:
Easy methods to Zip Information in Linux (GUI Methodology)
The GUI methodology to zip and unzip recordsdata is less complicated in comparison with the CLI methodology however lacks varied choices and options which can be helpful for a lot of customers. The tactic proven right here will work for all Linux distributions with any file supervisor. For this tutorial, we’re utilizing the Nautilus file supervisor in Ubuntu 20.04 LTS model.
1. First, open any file supervisor of your selection and navigate to the listing the place your recordsdata are situated.
2. Then, choose the recordsdata you wish to add to the zip file.

3. Proper-click on any one of many chosen recordsdata and choose “Compress.”

4. Right here, it’s worthwhile to give your compressed file a brand new title and choose the file format – .zip, .7z or .tar.xz. Lastly, click on on “Create” on the prime proper.

5. And that’s it. The compressed file shall be saved to the identical listing with the chosen format.
Easy methods to Unzip Information in Linux (GUI Methodology)
There are three other ways to unzip an archive file utilizing the GUI File supervisor on Linux:
- First, open the file supervisor and find the archive file.

- Then, right-click on the file and choose “Extract Right here.” It will extract your recordsdata into a brand new sub-directory with the identical title because the archive file.
2. Unzip All Information in a Completely different Listing
- First, open the file supervisor and find the archived file.

- Then, right-click on the file and choose the “Extract To” choice. It would open a brand new dialogue field.

- Choose the trail to which you wish to unzip all of the recordsdata from the left pane and click on on “Choose.”

- All of your recordsdata shall be extracted in a brand new sub-directory with the identical title because the archived file.

3. Unzip Solely Chosen Information
- First, open the file supervisor and find the archive file. Then, double-click on the file. It will open the Archive Supervisor.
- Choose a number of recordsdata by holding down the “CTRL” key whereas clicking on the file names you wish to choose. Then, click on on “Extract” within the prime left nook.

- Within the new dialogue field, select the trail and click on on “Choose” within the prime proper nook.

- All of your recordsdata shall be extracted in a brand new sub-directory with the identical title because the archived file.
Easy methods to Zip Information Utilizing Linux Command Line
The CLI methodology of compressing and decompressing recordsdata just isn’t solely sooner in comparison with the GUI methodology, however it additionally gives numerous choices to tinker with recordsdata. Whereas there are a number of instructions to compress and decompress recordsdata, zip
and unzip
are the most typical instructions as they’re cross-platform and have extensive on-line help.
1. Set up Zip and Unzip Packages
By default, each the packages – zip advert unzip – come pre-installed on most distros. Use the instructions beneath to put in them, if it’s not out there by default:
sudo apt set up zip
sudo apt set up unzip

2. Compress Information Utilizing Zip Command in Linux
The fundamental syntax to compress recordsdata utilizing the zip
command is as follows:
zip
, the place
is used to specify varied choices to compress recordsdata into zip.
file.zip
is the ultimate title of the zip file after compressing. Right here, giving the .zip extension is optionally available.
file(s)
is the file title which we wish to compress.
A few of the widespread choices to pair with the zip command are:
Choices
Description
-d
Used to take away a file from the zip archive.
-u
Used so as to add new recordsdata to a zipper file.
-m
This selection will delete the unique recordsdata after zipping them.
-r
It’s used to zip a complete listing.
-x
This selection is used to exclude the recordsdata whereas zipping.
3. Zip a Single File in Linux
To compress a single file, use the next command:
zip file.zip filename
It will compress the required file within the present listing whereas conserving the unique file intact.

4. Zip A number of Information in Linux
For compressing a number of recordsdata right into a single zip file, use the command given beneath:
zip zip_file file1 file2 file3
It will compress all the required recordsdata right into a single zip file.

5. Add Information to an Present Zip File
Typically you may miss a file whereas compressing a number of recordsdata. You’ll be able to add a single file to an current zip file. This may be finished utilizing the -u
flag, which stands for the replace. So as to add a brand new file to an current zip file, use the next command:
zip -u zip_file new_file
This command will add the new_file
to the prevailing zip_file

6. Take away File from an Present Zip File
Whereas zipping a number of recordsdata, it might be attainable that you’ll have added a delicate file to the zip file. Fortunately, you may simply delete a file from an current zip file by utilizing the next command:
zip -d zip_file file_to_be_deleted
Right here, the -d flag stands for delete which is able to delete the file file_to_be_deleted
from the prevailing zip_file
.

7. Easy methods to Zip a Listing in Linux
In some circumstances, you may wish to zip the whole contents of a listing, however writing all of the file names one-by-one within the command just isn’t possible. In such a case, you need to use the -r
flag to recursively or repeatedly add the recordsdata of a listing to the zip file.
zip -r zip_file directory_name
It will add all of the recordsdata in directory_name
to the zip_file

8. Create a password-protected zip file
Some delicate recordsdata should be password protected to stop unintended customers from accessing them. One option to defend the recordsdata is to transform the recordsdata to zip and encrypt them utilizing -e (encrypt flag). To create password protected zip file in Linux, use the next command:
zip -e zip_file file_1 file_2

You may be requested to enter and confirm a password for the compressed file.
Additionally, you can even add a number of flags whereas compressing utilizing the beneath command:
zip -r -e zip_file directory_name
Right here, we’re encrypting all of the listing contents into a zipper file.

Easy methods to Unzip Information Utilizing the Linux Command Line
Decompressing a zipper file means extracting all the data saved inside a zipper file utilizing varied instructions. In Linux, the most typical command to decompress a zipper file is the unzip
command.
The fundamental syntax to make use of the command is:
unzip
, the place
specifies varied choices to make use of throughout decompressionzip_file
specifies the zip file to decompress
1. View Contents of a Zip File
It’s at all times advisable to view the contents of a zipper file earlier than extracting it, in order to test for any malware ready to hurt your system. In Linux, you may view the contents of a zipper file with out extracting it, utilizing the next command:
unzip -l zip_file

To view extra details about the Zip File, use the -Z
flag, as proven beneath:
unzip -Z zip_file

2. Decompress a Single Zip File
To decompress a single zip file in the identical listing, use the next command:
unzip zip_file

3. Unzip a Single File to a Completely different Listing
If you wish to unzip a zipper file to a distinct listing, use the -d
flag as proven beneath:
unzip zip_file -d path/to/listing
4. Unzip A number of Information in Linux
Suppose there are a number of zip recordsdata and also you wish to extract all of them. Use the modified model of unzip command to extract all of the zip recordsdata as proven beneath:
unzip "*.zip
“
Understanding the command: Right here, we’re searching for all of the recordsdata with the extension .zip
which is specified by the wildcard "*
” which is then handed to the unzip command one after the other.

5. Decompress a Zip File Excluding Some Information
If, after viewing the contents of a zipper file, you wish to extract solely a number of the recordsdata. It could possibly simply be finished utilizing the unzip command in Linux. To extract a zipper file whereas excluding some recordsdata, use the -x flag to specify the filename you wish to exclude as proven within the following command:
unzip zip_file –x file_name

Information to Zip and Unzip Information & Listing in Linux
All of us must zip and unzip recordsdata regardless of the working system we’re engaged on. Zip recordsdata can typically assist to avoid wasting numerous treasured reminiscence by compressing the recordsdata. On this article, we’ve mentioned two strategies to zip and unzip recordsdata in Linux with examples. Utilizing the command line methodology is quicker, gives extra choices to work with, and is the popular methodology for many Linux customers. Do tell us within the feedback in case you face any points with the zip and unzip instructions
Steadily Requested Questions
The zip command is a well-liked command-line software used to compress recordsdata in Linux. It has many choices comparable to combining a number of recordsdata and directories right into a single zip file, compressing recordsdata with a password, and so forth. The unzip command is used to decompress or extract the contents from a zipper file.
Zip is an archive file format that’s used to compress a number of recordsdata collectively right into a single zip file. It reduces file dimension with out dropping information which makes it simpler to move or retailer. The unzip software is used to extract a zipper file within the unique format.
A zipper file is an archive format containing a number of recordsdata mixed and compressed right into a single file. Being in compressed file format, a zipper file occupies much less area and consumes much less bandwidth whereas transferring.
The post How to Zip and Unzip Files in Linux (Guide) appeared first on Ferdja.