How To Unzip In Linux?

The zip compressions are one of the most popular compression formats and algorithms. Even its name has used the term as compression and generally called zipping or unzipping. The zip files can be extracted by unzipping them. Even there are different tools the unzip command is the most popular and regular way to unzip a zip file.

Install unzip

Generally the unzip command and tool is not installed by the most of the Linux distributions. In order to use it we should install by using package managers.

Install unzip For Ubuntu, Debian, Mint, Kali:

$ sudo apt install unzip

Install unzip For CentOS, RHEL, Fedora:

$ sudo dnf install unzip

Unzip Command Help Information

The unzip command help information can be displayed by just running it without any option or parameter like below. This help information displays very basic information about the options.

$ unzip

List Zip File Contents

Before unzipping a file listing its contents, files an folders are important. The -l option can be used to list files.

$ unzip -l
   Length      Date    Time    Name
 ---------  ---------- -----   ----
        72  2021-06-10 14:21   cities.txt
 100109  2021-06-25 12:48   MyFile.csv
        23  2021-06-10 14:15   numbers.txt
 ---------                     -------
    100204                     3 files

We can see that files are listed with their names, length, date and time information.

Alternatively the long form --list can be also used to list contents of a zip archive.

$ unzip --list

Unzip A Zip File

Lets start with a simple example to unzip a zip file. We just provide the zip file name without any option in order to extract zip file content.

$ unzip

Unzip Into Different Directory or Path

By default the unzip command extracts the zip file into the current working directory. But we can change the unzip directory or path by using the -d option by specifiying the destination path.

$ unzip -d /mnt/

Suppress Unzip Output

By default the unzip command prints all unzipped files to the command line interface or standard output. But we can suppress the unzip output and complete it quitely by using the -q option like below.

$ unzip -q

Unzip Password Protected Zip File

Zip files can be encrypted and secured with passwords in order to prevent unauthorized access to the zip file contents. This requires a password in order to unzip the password-protected file. The -P option can be also used to provide password to decrypt the zip files.

$ unzip -P S3cR3t

Overwrite Existing Files with Unzip

While unzipping some files may be allready exist. By default the unzip command asks for every file which allready exist wheter overwrite or not. But we can set a global option in order to overwrite every existing file without asking one by one. The -o option is used to overwrite for all existing files.

$ unzip -o

Do Not Overwrite Existing Files with Unzip

Even unzip commands asks before overwriting for every file we may want to prevent overwriting. We can disable overwriting and skip these files to be extracted by using the -n option.

$ unzip -n

Unzip Multiple Zip Files

The unzip command can be used to unzip and decompress multiple zip files. We just provide the zip file names after the zip command like below.

$ unzip

Alternatively we can use the glob operator to unzip every zip archive by using the *.zip as the file named like below.

$ unzip  *.zip

See also  How To Find Linux OS Distribution and Version?

Leave a Comment