How to unzip a zip file using Terminal in Linux (Ubuntu, Linux mint, Debian …)?






In this post I am going to show you how to unzip the .zip file which you have download from the internet or got it from some means. This can be achieved in many different ways, but we will see how to use terminal to unzip the file.

Install unzip

So First of all we need to install unzip on our system if it’s not installed.
unzip command is used to extract files from a ZIP archive.
Run the following command to install unzip

unzip Syntex

Now Follow the steps below:

UnZip File

OPTION 1 – If the Zip File is in the same directory/folder in which your terminal is and we want to extract it in the present working directory.
Use the following command to achieve the above described scenario

if the zip file is protected with some password, then use the following command :

Please make sure you use -P (capital P) not -p because the are different options.

OPTION 2 –
If the zip file is not present in the same directory and we want to extract/unzip the file in different directory.
Use the following command to achieve the above described scenario

if we does not use option -d the file will be extracted to present working directory.

And if the zip file is password protected we can also use -P .

use tar Command in Linux / Unix

tar Command in Linux Unixtar is an acronym for Tape Archive. tar command is used to Manipulates archives in Linux/Unix. System administrators uses tar command frequently to rip a bunch of files or directories into highly compressed archive which are called tarball or tar, bzip and gzip in Linux/Unix system.

tar Syntex

Or
tar required Flags

tar optional Flags

Examples

Create tar Archive File by Compressing an Directory or a Single File

The terminal command below will create a .tar file called sample_dir.tar with a directory /home/codebind/sample_dir or sample_dir in present working directory.

Create tar Archive File
Here’s what those flags (-cvf) actually mean
-c, --create– create a new archive
-x, --extract, --get– extract files from an archive
-f, --file ARCHIVE– use archive file or device ARCHIVE

Create tar.gz or tgz Archive File by Compressing an Directory or a Single File

The terminal command below will create a .tar.gz file called sample_dir.tar.gz with a directory /home/codebind/sample_dir or sample_dir in present working directory.

Notice that we have added extra flag -z to the command.Here’s what the flag -z actually mean
-z, --gzip, --gunzip --ungzip– Compress the archive with gzip

Create tar.gz Archive

The command bellow will create a .tgz file. One this to notice is tar.gz and tgz both are similar.

Compressing Multiple Directories or Files at Once

Let’s say, For example we want to compress the sample_dir directory, the java_test directory, and the abc.py file to a tar file called sample_dir.tar.gz.
Run the following command to achieve the goal above.

Compressing Multiple Directories or Files at Once

Create .bzip2 Archive File by Compressing an Directory or a Single File

Notice that we have added extra flag -f to the command.Here’s what the flag -f actually mean

-f, --file ARCHIVE– use archive file or device ARCHIVE

Use bzip2 Compression

Extract .tar Archive File

We can extract or untar the compressed file using the tar command. The command below will extract the contents of sample_dir.tar to the present directory.

Extract .tar Archive File

 

 

 

 

The following command will extract or Untar files in specified Directory i.e. /home/codebind/dir_name in this case.

we have added extra flag -C to the command.Here’s what the flag -C actually mean

-C, --directory DIR – change to directory DIR

Untar files in specified Directory


Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com


Stuff I use to make videos

Windows notebook – http://amzn.to/2zcXPyF

Apple MacBook Pro – http://amzn.to/2BTJBZ7

Desktop - http://amzn.to/2zct252

Microphone – http://amzn.to/2zcYbW1

notebook mouse – http://amzn.to/2BVs4Q3

Screen Recording Software – Camtasia