How one can Unzip Recordsdata in Linux

ZIP is essentially the most extensively used archive file format that helps lossless knowledge compression. A ZIP file is an information container containing a number of compressed information or directories.

On this tutorial, we’ll clarify unzip information in Linux programs by the command line utilizing the unzip command.

What’s Unzip?

unzip is a utility that helps you record, check and extracts compressed ZIP archives.

Set up Unzip

unzip will not be put in by default in most Linux distributions, however you’ll be able to simply set up it utilizing the package deal supervisor of your distribution.

Set up unzip on Ubuntu and Debian

Set up unzip on CentOS and Fedora

How one can Unzip a ZIP file

In it’s easiest kind when used with none choice, the unzip command will extract all information from the required ZIP archive to the present listing.

To extract a ZIP archive into a particular listing, the consumer must have write permissions on that listing.

ZIP information don’t help Linux-style possession data, and all extracted information will likely be owned by the consumer that runs the command.

For instance, let’s say you downloaded the WordPress set up ZIP file. To unzip this file to the present listing, you’d merely run the next command:

How one can Suppress the Output from the unzip Command

By default the unzip command prints the names of all of the information it’s extracting and a abstract when the extraction is accomplished.

Use the -q change to suppress the printing of those messages.

How one can Unzip a ZIP file to a Completely different Listing

To unzip a ZIP file in a unique listing than the present one, use the -d change:

unzip -d /path/to/listing

For instance, to unzip the WordPress archive to the /var/www/ listing, you’d use the next command:

sudo unzip -d /var/www

Within the command above we’re utilizing sudo as a result of generally the consumer we’re logged in as doesn’t have write permissions to the /var/www listing. When ZIP information are decompressed utilizing sudo, the extracted information and directories will likely be owned by the consumer root.

How one can Unzip a Password Protected ZIP file

To unzip a file that’s password-protected, use the -P change adopted by the password:

unzip -P PasswOrd

How one can Exclude Recordsdata when Unzipping a ZIP File

If you wish to extract all of the information from a ZIP archive apart from one, use the -x change:

unzip -x file-to-exclude

Within the following instance we’re extracting all information and directories from the ZIP archive besides the .git listing:

unzip -x “*.git/*”

How one can Overwrite Current Recordsdata when utilizing Unzip

Let’s say you’ve already unzipped a ZIP file and you’re operating the identical command once more:

By default, unzip will ask you whether or not you prefer to overwrite solely the present file, overwrite all information, skip extraction of the present file, skip extraction of all information, or rename the present file.

exchange wordpress/xmlrpc.php? [y]es, [n]o, [A]ll, [N]one, [r]ename:

If you wish to overwrite current information with out prompting, use the -o change:

Use this selection with warning. The information will likely be overwritten and when you made any modifications to the information, the modifications will likely be misplaced.

How one can Unzip a ZIP File With out Overwriting Current Recordsdata

Let’s say you’ve already unzipped a ZIP file and also you made modifications to some information however you by chance deleted few information. You need to maintain the modifications and to revive the deleted information from the ZIP archive.

On this case, you’d use the -n choice which forces unzip to skip the extraction of a file that already exists.

How one can Unzip A number of ZIP Recordsdata

In case you have a number of ZIP information in your present working listing you’ll be able to unzip all information utilizing just one command:

Observe the one quotes across the *.zip. If you happen to forgot to cite the argument the shell will increase the wildcard character and you’re going to get an error.

How one can Checklist the Contents of a Zip File

To record the contents of a ZIP file, use the -l change:

Within the instance under, we’re itemizing all WordPress set up information:

The output will appear like this:

Size Date Time Title
——— ———- —– —-
0 2018-08-02 22:39 wordpress/
3065 2016-08-31 18:31 wordpress/xmlrpc.php
364 2015-12-19 12:20 wordpress/wp-blog-header.php
7415 2018-03-18 17:13 wordpress/readme.html

21323 2018-03-09 01:15 wordpress/wp-admin/themes.php
8353 2017-09-10 18:20 wordpress/wp-admin/options-reading.php
4620 2017-10-24 00:12 wordpress/wp-trackback.php
1889 2018-05-03 00:11 wordpress/wp-comments-post.php
——— ——-
27271400 1648 information


We’ve talked about unzip information in Linux, from the command line.

To create a ZIP archive on a Linux system, you’ll want to make use of the zip command.


Germany Devoted Server

Leave a Reply