Unzip Command in Linux (original) (raw)

Last Updated : 19 Jan, 2026

The unzip command in Linux is used to extract files and directories from ZIP archive files. It allows users to view, test, and decompress ZIP files directly from the terminal.

Suppose you have a file named 'archive.zip' that you want to extract which contains two files inside i as "file1.txt and file2.txt". We need to unzip it in the current directory.

**Command:

unzip archive.zip

**Output:

unzip archived files

**Syntax:

unzip [options] filename.zip

Options in the unzip Command in Linux

Provides a password for extracting encrypted ZIP files.

Options Description
-l Lists the contents of a ZIP file without extracting them.
-d dir Specifies the destination directory for extracted files.
-q Runs the extraction in quiet mode without displaying output.
-o Overwrites existing files without asking for confirmation
-p
-e Extracts files while preserving the original directory structure.
-t Tests the ZIP archive for errors or corruption before extraction.
-u Updates existing files and adds new ones from the ZIP archive without duplication.

Installation of Unzip Command

Step 1: Install Using Package Manager

sudo apt update sudo apt install unzip

sudo yum install unzip

sudo dnf install unzip

Step 2: Verify Installation

unzip -v

Step 3: Usage

unzip archive.zip

Examples of Unzip Command

To extract files to a specific directory, utilize the '-d' option followed by the desired destination path:

**Syntax:

unzip filename.zip -d /path/to/destination

**Example:

Suppose you possess a file named 'archive.zip,' and you intend to extract its contents into the directory '/path/to/destination.'

Extracting to specific directory

2. List Contents

To view the contents of a ZIP file without extracting, apply the '-l' option:

**Syntax:

unzip -l filename.zip

**Example:

Suppose Imagine you want to inspect the contents of 'archive.zip' without executing the extraction process.

unzip -l archive.zip

List Contents

3. Quiet Mode

Execute file extraction quietly by using the '-q' option:

**Syntax:

unzip -q filename.zip

**Example:

If you want to extract files from 'archive.zip' without displaying any messages.

unzip -q archive.zip

Quiet Mode

Quiet Mode

Quietly Extracted in Home

4. Overwrite Files

Overwrite current files without the affirmation of the usage of the ****'-o'** option:

**Syntax:

unzip -o filename.zip

**Example:

Extract files from 'archive.zip' and overwrite existing files without prompting for confirmation.

unzip -o archive.zip

Overwrite files

5. Password-Protected ZIP

If the ZIP file is password-protected, utilize the '-P' option to specify the password:

**Syntax:

unzip -P password filename.zip

**Example:

Suppose 'archive.zip' is protected with the password 'secure123.'

unzip -P secure123 archive.zip

Password protected zip

6. Encryption and Security

To extract encrypted files and maintain security, appoint the '-e' alternative:

**Syntax:

unzip -e filename.zip

**Example

If 'archive.zip' incorporates encrypted files, use the '-e' alternative for stable extraction.

unzip -e archive.zip

Encryption and  Security

This ensures the secure extraction of encrypted files from 'archive.zip,' maintaining the confidentiality and safety of the contents.

7. Update Existing Files

Update existing files during extraction using the '-u' option,

**Syntax

unzip -u filename.zip

**Example

If you want to update existing files from 'archive.zip' without overwriting newer variations, appoint the '-u' option.

unzip -u archive.zip

Update existing file

8. View Compression Information

Retrieve compression-associated details during extraction using the '-Z' option:

**Syntax:

unzip -Z filename.zip

**Example:

If you wish to look/inspect compression-related information while extracting files from 'archive.zip.'

unzip -Z archive.zip

View Compression Information

Features of Unzip Command