From videos to entire software packages, many files are compressed and stored using the .tar.gz format. While extracting a .tar.gz file isn't quite equally piece of cake as unzipping a .zip, information technology's still pretty straightforward.

As software becomes more powerful and media becomes more information-rich, file sizes continue to grow at exponential rates. As a result, information technology'due south condign increasingly common to store and ship files in compressed formats as .tar.gz.

Compressing and extracting these files, nevertheless, isn't ever intuitive. In this guide, we'll provide basic guides to unzip .tar.gz files in Linux and Windows, as well equally a few helpful tips and tricks.

What Are .tar and .tar.gz Files?

A ".tar" file is a collection of files compressed into a unmarried file or annal. Brusque for "Tape ARchive," the name "TAR" is a throwback to when files were stored on magnetic tape drives.

Thankfully, you don't need to exist a 1960s computer technician to apply and extract .tar files – nor practice modern .tar files fifty-fifty take anything to practice with old computers.

Just like the more familiar .zip files, .tar files shrink large files into a single package, making it easier to shop and send them through email, servers, and then on. As a consequence, information technology'due south become a common file extension for many open-source software packages and other resources.

But with .zip beingness the easier of the two to use, why use .tar in the commencement place? Every bit nosotros'll encounter in the next department, .tar comes with a few extra features that arrive the amend pinch format for certain files and applications.

Compressing and extracting files isn't always intuitive. 😅 Learn how to unzip .tar.gz files in Linux and Windows with help from this guide 🚀 Click to Tweet

.tar vs .null

Where most operating systems get in easy to extract and create .zip files, the same can't really exist said for .tar files — at to the lowest degree not in ways that are easy to notice.

Of course, that's not to say .tar files are some kind of "bottom" format than .zippo. Rather, they both accomplish the aforementioned chore (file compression) in the aforementioned way. Here's a breakdown of how it all works.

  • A .tar file is a collection of uncompressed files, sometimes known every bit a tarball. Since .tar doesn't compress anything, it requires a dissever pinch utility for compression. As nosotros'll see afterwards, one popular pinch utility is gzip, which compresses a .tar into a .tar.gz file.
  • A .zip file is a drove of compressed files. Rather than use a separate pinch utility to shrink the entire collection, .zippo automatically compresses each file within the collection.

Past now, y'all've probably noticed the major deviation between .tar and .zilch files: compression methods.

Where .naught files consist of many individually compressed files, .tar files are compressed as a unmarried package, leaving its files uncompressed. In other words, .zip files are a collection of compressed files, while .tar files are a compressed collection of files.

Merely does the compression method actually affair, especially if both methods technically produce compressed files?

It depends. For sending and storing, both .zero and .tar.gz files volition allow you to send relatively large packages equally a single file. Nevertheless, there are some pretty major differences when information technology comes to accessing data inside the files and the compression efficiency.

  • .zip files are more accessible. Since data in a .zero are compressed individually, they can besides exist accessed individually. By contrast, data in a .tar.gz is simply accessible after extracting the entire file.
  • .tar.gz files are more space-efficient. Since .tar files are compressed as a single entity rather than a group of individually compressed files, compression utilities tin can grouping similarities between files and cut down on space. In other words, compressing files equally a single group allows for more efficient compression methods, thereby saving space and reducing the overall size of the file.

If that's non entirely clear, don't worry. Technical details aside, all yous need to think is that .zero files are more attainable but less infinite-efficient, while .tar files are less attainable but more space-efficient. Every bit a upshot, ane isn't necessarily amend than the other — it's all a matter of application.

What's The Departure Betwixt .tar and .tar.gz Files?

While both .tar and .tar.gz refer to file athenaeum, a .tar.gz file is a .tar file that's been compressed or "zipped" using the gzip utility. Using gzip for compression is what gives the file a ".gz" double extension.

Though gzip is the nearly common pinch utility, it'due south not the only one. As you might imagine, using a different compression utility on a .tar file will result in a different double extension. Some common examples include .tar.bz2 (bzip2), .tar.br (Brotli), and .tar.zst (zstd), amidst many others.

As we'll see later, different pinch utilities may require different methods for extracting and unzipping files. Though we'll by and large focus on .tar.gz files, cheque out the end of the article for some quick tips on extracting .tar files in other formats.

Otherwise, keep reading to learn how to unzip .tar.gz files in Linux, macOS, and Windows.

How Do I Unzip a .tar.gz File in Linux Terminal?

Almost Linux distributions and macOS include built-in tools for zipping and unzipping .tar and .tar.gz files. While the tar utility is enough for nigh purposes, you'll demand the gzip utility to create .tar.gz files.

Unzip .tar.gz in Linux

You lot can unzip nearly .tar.gz and other compressed .tar files using the tar utility.

For the simplest method, begin by opening the concluding (CTRL+ALT+T) and navigate to the directory of the .tar.gz file you lot desire to unzip. Then enter the following command:

Extract .tar.gz file to current working directory:

                      tar -xf filename.tar.gz        

This command volition extract (-x) the file (-f) specified (in this example, filename.tar.gz) to the electric current directory. Annotation that this control likewise works with other common pinch formats such as .tar.bz2.

The tar control too comes with several other options. Like many Linux commands, one of these is a verbose output (-five) that prints the extracted files to the last window:

Extract .tar.gz file to current working directory and print output:

          tar -xvf filename.tar.gz        

Once again, the higher up commands will excerpt to the current working directory past default. You can utilize the -C pick to extract to a unlike directory (in this case, /home/user/files).

Extract .tar.gz file to a unlike working directory:

          tar -xf filename.tar.gz -C /home/user/files        

Only Extract Specific Files or Directories From .tar.gz in Linux

The tar command besides provides support for extracting only specific files or directories from a .tar.gz file. Simply add a infinite-separated list of the files you desire to excerpt.

Extract file1 and directory1 from .tar.gz file to electric current working directory:

          tar -xf filename.tar.gz file1 directory1        

Notation that this control will throw an fault unless you specify the verbal filename listed in the .tar file. As we'll encompass more in the next section, you can verify file names by listing contents with the tar -tf filename.tar.gz command.

You can also utilize --wildcards to excerpt all files with a certain extension or proper name.

Extract all files ending with ".txt" from .tar.gz file:

          tar -xf filename.tar.gz --wildcards '*.txt'        

Unzip .tar.gz From stdin in Linux

You can also extract .tar.gz direct from the standard input stream (stdin) by pipe it into the tar control using the decompression choice (-z).

For example, if you wanted to extract the .tar.gz file located at "https://kinsta.com/filename.tar.gz" (there'southward not actually a .tar.gz file here, only conduct with us), you'd use the wget control piped into tar.

Extract .tar.gz file from a URL:

          wget -c https://kinsta.com/filename.tar.gz -O - | sudo tar -xz        

List Contents of .tar.gz File in Linux

It'due south often useful to list the contents of a .tar.gz file without having to unzip the entire annal. The -listing (-t) option will output a listing of filenames.

Listing contents of a .tar.gz file:

          tar -tf filename.tar.gz        

You can also add together the verbose output option (-v) to provide detailed listings, including dates, securities/permissions, and more.

List detailed contents of a .tar.gz file:

          tar -tvf filename.tar.gz        

Many compression utilities also offer their own commands for list the contents of compressed files. For example, gzip allows y'all to listing the contents of a .gz file with the following command:

List detailed contents of a .gz file with gzip:

          gzip -l filename        

Zip and Unzip .tar and .tar.gz in Linux with gzip

You can create your ain compressed .tar files using compression utilities such every bit gzip. Gzip is ane of the well-nigh popular and available options, especially since it comes built in to most Linux distributions and macOS.

In the terminal, navigate to the working directory of the .tar file y'all want to compress and simply enter the following command:

Compress .tar file with gzip:

          gzip filename.tar        

You can just equally easily unzip the resulting .tar.gz file with the decompress (-d) option.

Decompress .tar.gz file with gzip:

          gzip -d filename.tar        

If you want to continue the original file after compression, in that location are two options. The offset is the -k option, and the other uses the -c option to output the compressed file to a different file, preserving the original.

Compress .tar file and keep original copy:

          gzip -c filename.tar        

Compress .tar file and store as a different file:

Subscribe At present

          gzip -c filename.tar > newfilename.tar.gz        

Similar the tar utility, gzip also allows you to zip and unzip multiple files or entire directories at a time.

Compress multiple files:

          gzip file1 file2        

Decompress multiple files:

          gzip -d file1 file2        

Compress all files in a directory:

          gzip -r directory1        

Decompress all files in a directory:

          gzip -dr directory1        

How Do I Unzip a .tar.gz File in Windows 10?

Similar Linux and macOS, the Windows ten operating system besides includes a congenital-in tar utility.

Dissimilar Windows' convenient graphical user interface (GUI) for unzipping .zip files, yous'll need to use the tar utility through the command line. Nonetheless, in that location are also many 3rd-party tools you tin install for a more than user-friendly experience.

Using the Command Line (cmd)

To access the Windows control line, search for "command prompt" or "cmd" in the search bar. Right-click the beginning result and select the "Run as administrator" choice.

The Command Prompt icon after searching
The Control Prompt icon after searching "cmd" in Windows 10/11

With the command prompt open, use the advisable commands to alter the electric current working directory (cd) to the location of the .tar.gz file you lot want to unzip. Alternatively, you lot can also specify a source and destination file path when using the tar utility.

Blazon one of the following commands and press "Enter."

Extract .tar.gz file to current working directory:

          tar -xvzf filename.tar.gz        

Excerpt .tar.gz file from source path to destination path:

          tar -xvzf C:\PATH\TO\SOURCE\filename.tar.gz -C C:\PATH\TO\DESTINATION        

Note that the tar utility in Windows has almost the aforementioned syntax equally it does in Linux and macOS. Hither nosotros've used the extract (-ten), verbose (-5), decompress with gzip (-z), and file (-f) options for a complete extraction with decompression and detailed output.

Using Tertiary-Party Tools

If the command line isn't your affair, there are plenty of user-friendly tools available to unzip tar.gz files.

Compressing a large number of files into a .zip using 7-Zip
Compressing a large number of files into a .null using 7-Zip

While there are many tools to choose from, the well-nigh popular include 7-Nada and WinZip. While slightly different, they are quite lightweight and offer a much simpler alternative to using the command line.

Some third-party tools also offer extended flexibility for converting between file types‌, saving more time if you desire to change between compression formats. Many are also available for Linux and macOS.

Compatibility options in 7-Zip including .tar and .gz.
Compatibility options in 7-Zip including .tar and .gz.

However, while tools like 7-Zip are free, many more "robust" solutions are but available for a price subsequently a trial menstruation. As a result, nosotros recommend sticking to free (simply trustworthy) tools or simply using the control line.

Troubleshooting Common Errors

Non every .tar.gz extraction is seamless — particularly if you're using the command line!

Where commands have little (if any) room for typos or omissions, many common errors are the result of small mistakes, misspellings, or incorrect formats. Thankfully, unless yous're somehow missing your tar or gzip utility, most mutual errors are very easy to fix.

tar: README: Not establish in archive

This fault occurs when trying to extract specific files or directories from a .tar.gz file using tar.

Mistake Input:

          tar -xf filename.tar.gz FILE        

Error Output:

          tar: FILE: Not plant in filename tar: Exiting with failure condition due to previous errors        

In this example, the user tried to extract the file titled "FILE" from filename.tar.gz. Nevertheless, tar was unable to discover FILE within .tar.gz, significant that the user either misspelled the name or that the file simply doesn't exist in filename.tar.gz. Another common cause of errors is case sensitivity, where Linux treats "FILE" and "file" as two split up entities.

Solution: Bank check the spelling and/or verify that the file exists in the .tar.gz archive by list the contents with tar -tf filename.tar.gz.

tar: Annal is compressed. Apply -z option

This mistake occurs if you endeavour to decompress a file without specifying a decompression utility, specifically -z for gzip.

Mistake Input:

          wget -c https://kinsta.com/filename.tar.gz -O - | sudo tar -10        

Notice that the "-z" is missing from what should be sudo tar -xz on the far right.

Error Output:

          tar: Archive is compressed. Use -z selection tar: Error is non recoverable: exiting now        

Solution: Specify a decompression pick such as gzip (-z) in the tar command.

gzip: stdin: not in gzip format

Many users study running the "right" commands only to find that their .tar.gz is "not in gzip format" – despite the .gz extension.

Error Output:

          gzip: stdin: non in gzip format tar: Child returned status 1 tar: Mistake exit delayed from previous errors        

This mistake commonly occurs when a .tar has been saved as a .gz despite having never been compressed using the gzip utility. It may sound like a silly mistake, but it'due south surprisingly mutual in situations where users directly rename files and their extensions (such every bit .tar and .gz) in the process.

Solution: Find a new copy of the .tar.gz file, or only extract it as a .tar file using tar -xf filename.tar instead. If this command besides throws an mistake, the next solution might help.

tar: Unrecognized archive format

Similar to the previous error, this fault occurs when an annal was saved as a .tar despite not existence a .tar annal.

Mistake Output:

          tar: Unrecognized archive format tar: Mistake get out delayed from previous errors.        

Solution: Find a new copy of the .tar or .tar.gz file, or effort extracting with gunzip filename.tar.gz instead. If the gunzip command doesn't work, try listing the contents with verbose output with tar -xvf filename.tar.gz and see if at that place'south a specific file causing the trouble. However, it's more likely that the file was never properly zipped every bit a .tar file in the first place.

FAQs

It's easy to get dislocated when navigating between .tar, .tar.gz, and .gz – not to mention zipping and unzipping them. Here are a few oft asked questions we normally hear from users working with .tar.gz files.

How Do I Open up A .tar.gz File?

Yous can open most .tar.gz files using the tar command built in to Linux, macOS, and Windows ten. If you're not comfortable with the terminal or command line, tertiary-political party tools such as 7-Zip offering a more user-friendly alternative.

Is .gz a .tar File?

While every tar.gz file is a .tar annal, non every .gz is a .tar file. The .gz extension represents the gzip compression format, which can exist applied to almost any file format to compress data and save space.

Is .tar.gz The Same As .nix?

Though both .zip and .tar.gz archive and compress files, they do then in different ways. Where .aught archives and compresses individual files, .tar simply archives individual files, leaving a divide pinch format such every bit .gz (gzip) to shrink all of them equally a single file/annal. In other words, .zip is a collection of compressed files, while .tar.gz is a compressed collection of files.

Is .tar.gz More Efficient Than .zilch?

Yeah. Since .tar.gz compresses multiple files all at once, it can accept reward of similarities between individual files to save on space. Generally speaking, a drove of files archived and compressed as a .tar.gz volition be more space-efficient (i.east., smaller) than the aforementioned drove compressed as a .zip.

Need a little help extracting files? This guide is here to help ✅ Click to Tweet

Summary

With Linux, macOS, and Windows 10 offering a built-in tar utility, information technology's easier than ever to unzip tar.gz files through the control line. Commonly, the only command you'll really need is:

          tar -xvzf filename.tar.gz        

Like many archive and compression formats, .tar.gz is an constructive way to relieve storage space and make it easier to send large amounts of information. If yous plan to distribute and store .tar.gz files on your website, Kinsta's managed hosting services tin aid make the most of your space.

For more data and to schedule a live demo, contact a hosting expert from Kinsta today.


Save time, costs and maximize site functioning with:

  • Instant aid from WordPress hosting experts, 24/7.
  • Cloudflare Enterprise integration.
  • Global audience reach with 34 data centers worldwide.
  • Optimization with our congenital-in Application Performance Monitoring.

All of that and much more than, in one programme with no long-term contracts, assisted migrations, and a 30-day-money-dorsum-guarantee. Check out our plans or talk to sales to notice the plan that's correct for you.