• *Wellcome Guest This Forum is created to help each other. Join us in our journey.

    * Guest Earn Piont Every Post, like, comment,and etc.

How to Open Tar file Linux


Simran Kaur

There are multiple files available on the internet which are downloadable for Linux but compressed as a tar file. Tar files store different files and squeeze them to keep the space and bandwidth in the downloading procedure.

These tar files work like a portable container to store various files, and it is also known as a tarball. However, many people can’t find out how to open a tar file in Linux, so you also want to learn how to open tar files and then read our article. This article will cover complete information on how to open tar files in Linux without facing errors.

How to Open Tar file Linux

tar Utility

Let’s consider that we want to extract and open a doc file, and then we can use the below command to unzip the file on Linux:

tar –xvzf doc.tar.gz

Remember that the tar.gz file is a combination of the .gz and .tar files, so it is an archive file with other files.

As you can see in the above command, we have used xvzf because these have specific meaning and instructions for the system, and they are:

  • x: This command instructs to extract the files from a particular zip file.
  • v: This command stands for verbose that works to list out the files
  • Z: This command instructs to decompress the files.
  • F: This command instructs the filename on which you want to work.

In case you want to create the tar.gz file, then use the following command:

tar –cvzf docs.tar.gz ~/Documents

The doc file is available in the document directory, so we have used Documents at the last of the commands.

In case you want to add various files to the tar file, then execute the following command:

tar -cvf documents.tar ~/Documents

In the above command, we have used cvf, so “c” where c is used to creates a new archive.
Finally, use the below command to extract a tar file in Linux:

tar –xvf docs.tar

gzip Utility

First, we will describe the procedure to extract or compress the Tar file on Linux:
Open the Linux terminal and execute the following command to compress the file as tar:

gzip xyz.txt

In the above command, we are compressing the xyz.txt file as a tar.gz file. After squeezing the file, use the ls to confirm that the file is compressed successfully.

For extracting the xyz.txt file, you can execute the following command:

gunzip test.txt

Finally, execute the ls command to confirm the file’s extension.
In case you want to compress all of the .txt files in a specific directory, then you can type:

gzip *.txt

In the above command, “*” is a wildcard for ” number of any characters.” Remember, this command can work on filenames with a specific extension .txt. You can use this way for all file types that include .jpg, .doc, and gzip.txt.


This is how you can easily extract and open tar files in Linux without any errors. As we have mentioned earlier, tar files store the files in a compressed manner, so you have to extract these files for using them. The above procedures are tried and tested on multiple Linux machines, but you have to follow all of these steps carefully.

Credit to linux

Latest threads