How to Unzip or Untar tar.gz (The Easy Way)

Tar files are designed to take one or more files and stick them into a single self-contained file called a “tape archive” (because when tar was first invented, it was used to put data on magnetic tapes). Having a VPS will make it a lot easier to untar tar.gz files, but this guide is designed to help you no matter what hosting plan you have.

A lot of people think a .tar file is exactly the same as a .zip file, but that’s not true, because a tar archive isn’t necessarily compressed. The files on the archive can be compressed using separate systems, but the tar format itself only acts like a container for files.

When you see a file with a .tar extension, this means the file isn’t compressed. (This does happen, but it’s admittedly quite rare.) A file with a .tar.gz or .tar.bz2 extension denotes a compressed archive file.

Installing tar

Tar is already available on Linux and a few other OS. But that doesn’t mean it’s exclusively available on Linux and these other OS. If you’re using Windows, the easiest way to manage .tar files is to install the LGPL open source 7-Zip utility. Even though the name of this utility makes it sound like it only works with .zip files, it actually works quite happily with tar archives and will even give you commands for the Windows Command-Line Interface.

If you want a tar-specific solution, though, you can use Cygwin or WSL on Windows 10 to install GNU tar.

How to make a tarball

The contents of a tar file are known as a tarball. (Presumably because this is very funny to say.) When you use a Graphical User Interface, you can make a tarball in just three steps:

  1. Make a directory
  2. Put your files in the directory
  3. Right-click on the directory and select Compress

And now you have your very own tarball! (The process is basically the same in a shell.)

What does it mean to untar tar.gz files?

To untar tar.gz files means to extract the contents of the tarball.

How do you untar tar.gz files?

To extract or untar tar.gz files from an archive, enter:
$ tar -zxvf {file.tar.gz}

So, for example, if your tar file is called cursedpizzatoppings.tar.gz, enter the following at a shell prompt to extract files:
$ tar -zxvf cursedpizzatoppings.tar.gz

To extract the file peasandmayo.doc from cursedpizzatoppings.tar.gz, enter:
$ tar -zxvf cursedpizzatoppings.tar.gz peasandmayo.doc


  1. -z: Work on gzip compression automatically when reading archives.
  2. -x: Extract tar.gz archive.
  3. -v: Display progress and extracted file list on screen.
  4. -f: Read the archive from the archive to the specified file. (In this case, read cursedpizzatoppings.tar.gz.)
  5. -t: List the files in the archive.
  6. -r: Add files to the end of the tarball.

–delete (GNU/Linux only): Delete files from the tarball

How to untar tar.gz archives

If you want to extract an entire archive, specify the archive file name with no individual file names as arguments. For example, to extract the entire cursedpizzatoppings.tar.gz archive, enter:

tar -zxvf cursedpizzatoppings.tar.gz

How to list files in the archive:

To see a list of all the files in a tarball, enter:

$ tar -tvf cursedpizzatoppings.tar.gz (Substituting your own archive name, naturally.)

How to add to an existing tarball

You needn’t untar tar.gz files every single time you want to add a new file. In a Linux OS, you can open the tar archive just like you’d open any other directory. You can also add files whenever you want.

How to choose where to send your untarred tar.gz files:

If you want to extract the files to a location other than the current directory, you’ll need to specify a target directory using -c (specified directory).

tar  -xvjf  peasandmayo.tar.gz   -C  ~/Desktop/Images/

If you look in your Desktop/Images directory, you’ll see your file.

If, for some reason, you need to create a directory and extract the files into it using just one command, here’s the command you need to enter:

mkdir  -p  ~/Desktop/Images/Downloaded && tar xvjf   peasandmayo.tar.gz    -C ~/Desktop/Images/Downloaded/

The Takeaway

Tar files are a great way to conveniently store lots of massive files in a single location. They’re like .zip files in that way, except that tar files aren’t necessarily compressed. Tar is available on Linux, so if you use a Linux OS, you’ll already have the power to wield tar as you see fit, but you can always install compatible programs if you use Windows or some other OS.

To untar tar.gz files, you really only need to know the syntax, and the entire world of tarballs will expand beneath your fingertips. The good news is that the syntax isn’t difficult to learn or use, and if you get stuck, you can find lots of resources (like this blog post!) to help you. Good luck and may your tar files come untarred with astonishing ease!