+1 (506) 500-5957 sales@monovm.com

How to Extract Tar Gz File in Linux - [Untar tar.gz]

This blog post will help you to get information about how to unzip tar.gz file, untar tar.gz file, and extract tar GZ file in Linux? Also, you can get a detailed guide to executing the overall process.

Posted: 01 Jul, 21 Updated: 05 Mar, 23 by Antoniy Yushkevych 5 Min

List of content you will read in this article:

TAR is an abbreviation for Tape ARchive. This command was primarily developed to fulfill the purpose of creating archives and storing the files on magnetic tape. Hence, the name Tape Archive. 

The tar command helps you to generate several tar archives as it converts as many files as you want into archives. When we talk about the tar command, it can be used in ample ways. You can use it to add files to the archive, delete files, or extract tar archives. The list is pretty long.

Being a techie, it is highly evident that you are already familiar with the .tar.gz files. 

These files are commonly known as ‘tarballs’. They are used by Linux, macOS, or even Windows users for backups or data archival.

Now, there are various methods to compress tar files. One of the most used methods to compress a file is Gzip. Moreover, whenever you compress the tar archive with gzip, it ends with .tar.gz or .tgz extension. 

Besides, if you are a Windows user, you may need to download the 7zip tool to extract tar.gz file in Linux. A lot of such third-party applications are also available in the market. They do come with a drawback, that is, they do not work every time.

In this article, we are going to make you familiar with some ways to unzip/untar/extract tar.gz archives in both Linux and Windows. 

Let’s begin!

It is a simple process to extract tar.gz file in Linux.

Before that, take a look at the meaning of these symbols:

1. x: This option is used to extract the files.

2. v: It means Verbose. It helps to list the files in the archive. 

3. z: This is used to uncompress a file.

4. f: You can easily keep a name for the file by using this option.

To start with, if the file is compressed by a gzip compressor, you can apply the following command:

tar -xzf filename.tar.gz

In this command, filename.tar.gz is the name of the archive that you want to unpack tar.gz file. Additionally, if you want to seek more information about the files, you may use the -v option. Here, -v stands for Verbose. Take a look:

tar -xvzf filename.tar.gz

Easy, right? But somehow if your work impedes and you don’t get the desired results, follow another method.

Follow the below-given procedure to unzip .ta.gz file without gzip command.

  • Now, use the following command:

tar -xf filename.tar.gz

And your work is done. 

  • Moving on, if you wish to uncompress tar.gz file in a directory, follow this command:

$ tar xvzf file.tar.gz -C /path/to/somedirectory

Here, -C is used to mention the particular path to store the file. 

  • The next command is to extract a .doc file from the .tar.gz file. Take a look at the command below:

$ tar -xvzf file.tar.gz test.doc

  • Moving on, if you want to extract some particular files from a tar.gz file, use this command:

tar -xf archive.tar.gz file1 file2

  • This command is specifically used for files. If you want to extract some directories, use the following command:

tar -xf archive.tar.gz dir1 dir2

Simple, right?

  • Moreover, to print the name of the files for extraction using the tar command, use this command:

tar -xvf archive.tar.gz

Sometimes you get an error message like this:

tar -xf archive.tar.gz README

It implies that the files that you want to extract don't exist.

  • Moving on, if you want to list the content of your tar.gz file, then use the below-mentioned command:

tar -tf archive.tar.gz

Here is the output.




Well, these were some of the commands to extract tar.gz files in Linux. 

The next segment talks to you about extracting tar.gz files in Windows. Let’s see how!

If you are a Windows user, here are a few steps for you to follow so that you can easily extract/untar tar gz file.

.tar.gz files. 

Step 1. Tap on Start on your Windows 

Step 2. Now, go to the Command Prompt and click right. Choose Run as Administrator option

Step 3. Enter this command in the command prompt: tar -xvzf C:\PATH\TO\FILE\FILE-NAME.tar.gz -C C:\PATH\TO\FOLDER\EXTRACTION

You can add any desired path to store your files. After you press enter, all the files will be extracted to the path that you mention. 

If you do not wish to use the command line method, don’t worry. There is another solution. You can simply head towards the File manager and click right on the file that you wish to extract. Choose the Extract option. 

That’s it. You are done. 

In a nutshell, tar.gz files or tarballs are used to archive data and backups. It is necessary to decompress and extract these files in order to get your work going. 

There are specific ways and methods to conclude your task through various steps and commands. 

As you have seen, this article assists you to extract tar.gz file [unzip tar.gz file, untar tar.gz file], whether you are a user of  Linux or Windows. 

We hope that the information provided in this article helps you in the best possible way. 

Keep learning. Keep evolving.

People are also reading:

Antoniy Yushkevych

Master of word when it comes to technology, internet and privacy. I'm also your usual guy that always aims for the best result and takes a skateboard to work. If you need me, you will find me at the office's Counter-Strike championships on Fridays or at a.yushkevych@monovm.com