logo logo

The next-generation blog, news, and magazine theme for you to start sharing your stories today!

The Blogzine

Save on Premium Membership

Get the insights report trusted by experts around the globe. Become a Member Today!

View pricing plans

New York, USA (HQ)

750 Sing Sing Rd, Horseheads, NY, 14845

Call: 469-537-2410 (Toll-free)

hello@blogzine.com

How to Unzip a Tar.gz File in Linux

avatar
Louis Ferguson

An editor at Blogzine


  • đź•‘ 4 minutes read
  • 3 Views
How to Unzip a Tar.gz File in Linux

Tar.gz is one of the most common file compression formats in Linux today. Unlike ZIP, RAR and 7ZIP, it is a combination of two different file formats: TAR and GZIP. This tutorial shows how to unzip a tar.gz file using both graphical and command tools that are already a part of your Linux distribution.

What Is Tar.gz?

A tar.gz file is a combination of tar and gzip. The former encodes your file in a sequential archive format suitable for magnetic tapes, while the latter compresses it to a smaller size.

The biggest advantage of tar.gz files is that they are more compact and easier to handle than other compressed archive formats.

In addition, gzip is a format that is as old as the Internet itself, so tools that can compress and decompress tar.gz files are widely available for almost all platforms.

Unzip Tar.gz Files Using Your File Manager

Most, if not all, of Linux file managers can unzip a tar.gz file. For example, the Nautilus file manager in Ubuntu can unzip tar.gz via the context menu.

  • Open your file manager in Linux.
  • Navigate to the folder that contains your tar.gz archive.
A window showing a single tar.gz archive.
  • Right-click your archive and select “Extract to.”
A screenshot highlighting the
  • Select the directory in which to save the extracted files. Click “Select.”
A window showing the location where you can unzip the tar.gz file.

Unzip Tar.gz Files Using the Command Line

  • Open a terminal and go to the directory that holds your tar.gz file.
A terminal showing the contents of the Downloads directory.
  • Unzip your tar.gz file with the tar command:

tar -xzvf maketecheasier.tar.gz

A terminal showing the unzipping process using tar.

You can also tell tar to extract your archive on a different directory. For example, the following command will unzip my “maketecheasier.tar.gz” file to my “Documents” folder:

tar -xzvf maketecheasier.tar.gz -C /home/$USER/Documents

A terminal showing the contents of the Documents folder after unzipping.

Unzip Tar.gz Files with Xarchiver

While the file manager in most distributions can work with tar.gz, there are cases where you need a more powerful tool to do the job. Xarchiver is a highly flexible graphical program that can unzip archives and portable package formats in Linux.

  • Install Xarchiver in Debian and Ubuntu by running the following command:

sudo apt install xarchiver

A terminal showing the installation process for Xarchiver.
  • Run “Xarchiver.” Click “Archive,” then “Open.”
A screenshot showing the
  • Navigate to your tar.gz file and click “Open.”
A screenshot showing the file picker dialog for Xarchiver.
  • Click “Action,” then “Extract.”
A screenshot showing the

In the option box that shows up, choose how and where you want to unzip your tar.gz file.

A screenshot of Xarchiver's
  • Click the “Touch files” checkbox. This will tell Xarchiver to unzip the contents of your archive, regardless of the files in the destination directory.
A screenshot highlighting the
  • Click the “Extract” button to unzip your tar.gz file.
A screenshot highlighting the

Unzip Tar.gz Files with Unpack

Unpack is a simple third-party Bash wrapper script that allows you to unzip almost any type of modern archive format in Linux. Unlike tar and Xarchiver, it aims to be a simple, single command solution to extract Tar.gz files.

  • To start installing Unpack, clone the Unpack script from the author’s Git repository:

git clone https://github.com/githaff/unpack.git

A terminal showing the cloning process for the Unpack source.
  • Make a “bin” folder in your user’s home directory:

mkdir /home/$USER/bin

  • Copy the Unpack script to your new “bin” folder:

cp /home/$USER/unpack/unpack /home/$USER/bin/

  • Enable the execute bit of your new Unpack script:

chmod u+x,go-x /home/$USER/bin/unpack

A terminal showing the correct permission bits for Unpack.
  • Use unpack to unzip your tar.gz file. For example, running the following command will extract the “maketecheasier.tar.gz” file on my “Downloads” folder:

unpack /home/$USER/Downloads/maketecheasier.tar.gz

A terminal showing the contents of the Tar.gz file.

Frequently Asked Questions

Is it possible to extract a tar.gz file in macOS and Windows?

You can unzip a tar.gz file in macOS by double-clicking it in the Finder program. You can also use the same tar command to extract the tar.gz file in the Terminal.

To unzip a tar.gz file on Windows, you can either download the 7zip archive utility or install Linux through the WSL.

Is it possible to extract multiple tar.gz files at the same time?

You can unzip multiple tar.gz archives in the same folder by running a Bash for loop inside your archive directory: for i in $(ls); do tar -xvzf $i ; done. You can also use Xarchiver’s Multi-Extract tool to extract multiple tar.gz files.

Can Xarchiver selectively extract tar.gz files instead of overwriting them?

Yes. Uncheck the “Touch files” option on the Extract Files dialog box, then enable either the “Update existing files” option or the “Freshen existing files only” checkbox.

Image credit: Unsplash. All alterations and screenshots by Ramces Red.

  • Facebook
  • Tweet


Leave a Reply

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