Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Linux unzip Command

Linux unzip Command

Linux Command Reference Linux Command Reference

The Linux unzip command is used to extract compressed files in .zip format.

The unzip tool can extract .zip files containing multiple files and directories, and is widely used to handle cross-platform compressed files.

Syntax



unzip [options] file.zip

options parameters:

Example

Extract a .zip file



unzip archive.zip

This command extracts the contents of archive.zip into the current directory.

** Extract to a specified directory**



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

This command extracts the contents of archive.zip into the specified /path/to/directory directory.

** List the contents of a .zip file**



unzip -l archive.zip

This command lists all files and directories in archive.zip without actually extracting them.

** Test the integrity of a .zip file**



unzip -t archive.zip

This command tests the integrity of the archive.zip file to ensure it is not corrupted.

** Exclude specific files when extracting**



unzip archive.zip -x "*.log"

This command extracts archive.zip but excludes all .log files.

** Do not overwrite existing files when extracting**



unzip -n archive.zip

This command extracts the files in archive.zip, but if a file with the same name already exists in the target directory, that file is skipped and not overwritten.

** Extract files and overwrite existing files**



unzip -o archive.zip

This command overwrites existing files with the same name in the target directory when extracting archive.zip, without prompting the user.

** Do not preserve the directory structure when extracting**



unzip -j archive.zip

This command extracts all files from archive.zip into the current directory without preserving the original directory structure.

Notes

Linux Command Reference Linux Command Reference