How to unzip a zip file using the Linux and Unix bash shell terminal

I grabbed a file from the Github public repo on my Linux VPS hosted at AWS. How do I unzip the file using bash ssh terminal? How can I unzip a file on Ubuntu/CentOS/Debian Linux/UNIX-like server?

You can use the unzip or tar command to extract (unzip) the file on Linux or Unix-like operating system. Unzip is a program to unpack, list, test, and compressed (extract) files and it may not be installed by default.

Use unzip command to unzip a zip file

The syntax is:
unzip {}
Use the following syntax if you want to extract/unzip to a particular destination directory:
unzip -d /dest/directory/ {}
For example, unzip a zip file named using zip command:
To unzip a zip file named using zip command to a /tmp/data/ directory:
unzip -d /tmp/data/
Sample session:

Fig.02: How to unzip a zip file from the Terminal using unzip command

A note about bash: unzip: command not found

If the unzip command NOT installed on your Linux or Unix box, then run any one of the following commands as per your Linux distribution to install the unzip command.

Make sure you run the following command as the root user. For instance:
sudo command
su -

Installing unzip on Debian/Ubuntu Linux

Use the apt-get command or apt command to install unzip command:
sudo apt-get install unzip
sudo apt install unzip

Install unzip on Arch Linux

Use the pacman command to install unzip command:
pacman -S unzip

CentOS/RHEL/Scientific/Oracle Linux install unzip command

Use the yum command or dnf command to install unzip command:
yum install unzip

Fedora Linux install unzip

Use the dnf command to install unzip command:
dnf install unzip

Installing unzip on Suse/OpenSUSE Linux

Use the zypper command to install unzip command:
zypper install unzip

FreeBSD Unix install unzip

To install the unzip port, run:
# cd /usr/ports/archivers/unzip/ && make install clean
To add the package rung pkg command:
# pkg install unzip

OpenBSD Unix install unzip

Type the following pkg_add command to install unzip package:
# pkg_add -v unzip

macOS Unix install unzip CLI

Let us install Homebrew on macOS. Once installed type the following brew command to install unzip utility:
$ brew install unzip

Use tar command to unzip a zip file

The syntax is:
tar xvf {}
tar -xvf {}

Use the following syntax if you want to extract/unzip to a particular destination directory:
tar xvf {} -C /dest/directory/
tar -xvf {} -C /dest/directory/

For example, unzip a zip file named using tar command:
tar xvf
To unzip a zip file named using tar command to a /tmp/data/ directory:
tar xvf -C /tmp/data/
ls -l /tmp/data/
cd /tmp/data/
ls -l

Sample session:

Fig.01: How to use a tar command to unzip a file on Linux/Unix-like terminal

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 3 comments so far... add one

CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
3 comments… add one
  • Hello May 26, 2017 @ 18:46

    I’d just like to interject for a moment. What you’re referring to as Linux, is in fact, GNU/Linux, or as I’ve recently taken to calling it, GNU plus Linux. Linux is not an operating system unto itself, but rather another free component of a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX.

    Many computer users run a modified version of the GNU system every day, without realizing it. Through a peculiar turn of events, the version of GNU which is widely used today is often called “Linux”, and many of its users are not aware that it is basically the GNU system, developed by the GNU Project.

    There really is a Linux, and these people are using it, but it is just a part of the system they use. Linux is the kernel: the program in the system that allocates the machine’s resources to the other programs that you run. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. Linux is normally used in combination with the GNU operating system: the whole system is basically GNU with Linux added, or GNU/Linux. All the so-called “Linux” distributions are really distributions of GNU/Linux.

  • Cameron Sep 20, 2017 @ 20:08

    unzip worked for a zip file, tar xvf did not work for me…

    tar: This does not look like a tar archive
    tar: Skipping to next header
    tar: Exiting with failure status due to previous errors

  • anonymous Jan 16, 2021 @ 8:09

    You cannot use tar to extract a zip file. I demand that you fix this web page.

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Problem posting comment? Email me @