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

I grabbed a master.zip 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 tar command to unzip a zip file

The syntax is:tar xvf {file.zip} tar -xvf {file.zip} Use the following syntax if you want to extract/unzip to a particular destination directory:tar xvf {file.zip} -C /dest/directory/ tar -xvf {file.zip} -C /dest/directory/ For example, unzip a zip file named master.zip using tar command:tar xvf master.zip To unzip a zip file named master.zip using tar command to a /tmp/data/ directory:tar xvf master.zip -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

Use unzip command to unzip a zip file

The syntax is:unzip {file.zip} Use the following syntax if you want to extract/unzip to a particular destination directory:unzip -d /dest/directory/ {file.zip} For example, unzip a zip file named master.zip using zip command:unzip master.zip To unzip a zip file named master.zip using zip command to a /tmp/data/ directory:unzip -d /tmp/data/ master.zip 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.

Install unzip on OpenBSD unix

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Your support makes a big difference:

I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft takes a lot of my time and hard work to produce. If everyone who reads nixCraft, who likes it, helps fund it, my future would be more secure. You can donate as little as $1 to support nixCraft:

2 comment

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.