Skip to content

unzip Linux Command Guide

The Linux unzip command is used to extract files and directories from compressed archives. It is a versatile tool that supports various compression formats such as zip, gzip, and bzip2. By using the unzip command, you can easily extract the contents of an archive to a specified directory. Additionally, you can choose to only extract specific files or directories from the archive. This command is essential for managing compressed files efficiently in a Linux environment.

unzip Syntax:

Terminal window
unzip [options] zipfile

Options:

OptionDescription
-lList the contents of the zipfile
-vBe verbose when extracting files
-tTest the zipfile integrity
-dExtract files to a specific directory
-qPerform operations quietly (no output)
-oOverwrite files without prompting
-PSpecify a password for decryption

Parameters:

ParameterDescription
zipfileThe file to be unzipped

unzip Command Samples:

Extract a ZIP archive into the current directory

Terminal window
unzip archive.zip

Extracts all files from the archive.zip into the current directory.

Extract a ZIP archive into a specific directory

Terminal window
unzip archive.zip -d /path/to/directory

Extracts all files from the archive.zip into the specified directory.

List the contents of a ZIP archive

Terminal window
unzip -l archive.zip

Displays a list of files in the archive.zip without extracting them.

Extract a specific file from a ZIP archive

Terminal window
unzip archive.zip specific-file.txt

Extracts only the specific-file.txt from the archive.zip.

Overwrite files during extraction

Terminal window
unzip -o archive.zip

Overwrites existing files while extracting from the archive.zip.

Extract a ZIP archive with a specific password

Terminal window
unzip -P password archive.zip

Extracts the files from the password-protected archive.zip using the specified password.

Extract and display detailed information about files

Terminal window
unzip -v archive.zip

Extracts the files from the archive.zip while displaying detailed information about each file.

unzip FAQ:

How do I use unzip in Linux?

To use the unzip command in Linux, execute the following command:

Terminal window
unzip file.zip

How do I unzip a specific file in Linux?

To unzip a specific file from a ZIP archive in Linux, you can use the following command:

Terminal window
unzip archive.zip specificfile.txt

How do I unzip a ZIP archive into a specific directory in Linux?

To extract a ZIP archive into a specific directory in Linux with the unzip command, you can use:

Terminal window
unzip archive.zip -d /path/to/directory/

How do I list the contents of a ZIP file without extracting it in Linux?

To list the files inside a ZIP archive without extracting it in Linux, you can run the following command:

Terminal window
unzip -l archive.zip

How do I overwrite existing files when unzipping in Linux?

To overwrite existing files when unzipping with the unzip command in Linux, use the -o flag like this:

Terminal window
unzip -o archive.zip

How do I unzip a password-protected ZIP file in Linux?

To unzip a password-protected ZIP file in Linux using the unzip command, you can specify the password with the -P option as follows:

Terminal window
unzip -P password archive.zip

Applications of the unzip command

  • Extracting files from zip archives
  • Viewing the contents of zip files
  • Extracting specific files from zip archives
  • Decoding encrypted zip files
  • Overwriting existing files while extracting
  • Extracting files with specific permissions and timestamps
  • Extracting files with specific prefixes or extensions
  • Extracting zip files to a specific directory