The Linux 'unzip' Command

The 'unzip' command supports command-line options to customize its use

Zipping files is an easy, efficient way to transfer data between computers and servers. When files are compressed, they not only save disk space on a local drive but also make it easier and more convenient to download files from the internet, using far less bandwidth in most cases than sending full-size files.

Person unzipping files via the command line
Lifewire / Ashley Nicole DeLeon

After you receive a zipped archive, decompress it with a single Linux command. The unzip command supports many switches to customize how the command works.

Decompress Single ZIP Files

unzip linux file

The basic syntax for decompressing a file is:

unzip filename

Assume you've zipped an archive titled sample.zip that contains three text files. To unzip this file to the current folder, run the following command:

unzip sample.zip

Unzip several files by listing them all sequentially—e.g., unzip first.zip second.zip third.zip—or by using a wildcard, e.g., unzip *.zip.

Alternatively, use the graphical user interface for your desktop environment to extract zip files. Each DE uses different approaches, but in general, a right-click on the zipped file and an uncompress or extract menu option will get you started.

Options

Use the following options to modify how the base unzip command works:

  • -d /path/to/extact/location: Unzip an archive to a different directory.
  • -j: Unzip without creating new folders, if the zipped archive contains a folder structure.
  • -l: Lists the contents of an archive file without extracting it.
  • -n: Do not overwrite existing files; supply an alternative filename instead.
  • -o: Overwrite files, if relevant.
  • -P password: Supplies a password to unzip a protected archive file.
  • -q: Unzips without writing status messages to the standard output.
  • -t: Tests whether an archive file is valid.
  • -v: Displays detailed (verbose) information about the archive without extracting it.
  • -x filename: Extract the archive but do not extract the specified files.