How to Extract/Unzip .tar Files in Linux

Today’s many files are available on web in compressed format. The files may be images,videos, documents,source code of projects etc. Some compressed formats are very popular like .zip, .tar.gz, .tar.bz2, etc. So our this tutorial is based on Extract procedure of compressed files in Linux. The .tar compression technique mostly used for Linux user, many Linux software are come in compressed (.tar) format. For example your new internet dongle drivers for Linux,your printer drivers,any other third party software, these are available in compressed format.

Extract tar files in Linux (www.digitendency.com)

What is tar files:

A TAR file is an archive file that contains one or more files inside. This is often done to ease distribution of a large set of files over the Internet.The format was originally designed for backup purposes using tapes, however it is quite often used for downloads and application packages. It enables you to put a number of files together into one single file, which makes it much easier to either archive the files, or distribute them. For more details on tar click here.

How to Extract tar.gz files:

To extract tar.gz files follow the below steps:
Step 1: First open your terminal (ctrl+alt+t) and go to desired location where your file (Compressed file) saved. For example if your file save on desktop then go to desktop via terminal :
For desktop location in your terminal type following command
cd Desktop

Now you on desktop in your terminal. Type following command to extract tar.gz file:

tar -zxvf filename.tar.gz
Here filename is your custom file name which you want to extract.
here

  • z stand for work on gzip compression automatically when reading archives.
  • x stand for extract archives
  • v stand for display progress
  • f stand for read the archive from the archive to the specified file.

Note: If file have only .tar extension then only use -xvf options.

    How to Extract tar.bz2 files:

    To extract tar.bz2 files follow the below steps:

    Step 1: First open your terminal (ctrl+alt+t) and go to desired location where your file (Compressed file) saved. For example if your file save on desktop then go to desktop via terminal :
    For desktop location in your terminal type following command
    cd Desktop

    Now you on desktop in your terminal. Type following command to extract tar.bz2 file:

    tar -xvjf filename.tar.bz2

    Here filename is your custom file name which you want to extract.

    How to Extract single file from TAR Archive:

    Some times user don’t want to extract whole directory from tar archive,  because he only want a single file from given archive in this case you can easily extract single file via this command:
    tar -xvf archive.tar desiredfile.txt
    tar -xzvf archive.tar.gz desiredfile.txt 
    tar -xjvf archive.tar.bz2 desiredfiler.txt 

    In above example we give commands for all compression formats.

    How to Extract a Directory from TAR Archive:

    If the user want to extract only single directory then:

    tar -xvf archive.tar directoryname 
    tar -xzvf archive.tar.gz directoryname 
    tar -xjvf archive.tar.bz2 directoryname 

    In above example we give commands for all compression formats.

    How to Extract zip files in Linux:

    you can easily extract zip files via gzip package.
    gzip (GNU zip) is a compression utility designed to be a replacement for compress. Its main advantages over compress are much better compression and freedom from patented algorithms. It has been adopted by the GNU project and is now relatively popular on the Internet.
    to unzip any archive type following command in terminal:

    unzip archive.zip

    Note: The above unzip command only work when your system have gzip package.

    Feel Free to comments & Share

    Leave a Reply