Many backup tools and software distributions ship files in .tar.gz format. The format bundles multiple files with TAR, then shrinks the bundle with gzip — which is why a single command handles both steps. Below are the exact commands for Linux, Windows, and macOS.

What Is a .tar.gz File?

A .tar.gz file (also written as .tgz) is two formats combined. TAR groups files into a single package. GZIP then compresses that package. The combination is standard on Unix-based systems and the default output of many server backup and deployment tools.

ComponentPurpose
TARGroups multiple files into one package
GZIPReduces the package size through compression
.tgzShortened alias for .tar.gz

How to Unzip tar.gz Files on Linux

Linux includes the tar command by default. Open a terminal and run:

tar -xvzf filename.tar.gz

What each flag does:

FlagRole
-xExtract the archived contents
-vPrint each filename during extraction
-zApply gzip decompression
-fPoint to the archive file

If your backup is named sitebackup.tar.gz, the command is:

tar -xvzf sitebackup.tar.gz

This drops everything into the current working directory. To extract into a specific folder, add -C:

tar -xvzf sitebackup.tar.gz -C /home/user/restored/

The destination folder must exist before you run the command. Use mkdir -p /home/user/restored/ to create it if needed.

How to Unzip tar.gz Files on Windows

Windows 10 version 2004 and later ships with a built-in tar utility. If you’re on an older version, or prefer a GUI, 7-Zip and WinRAR both handle .tar.gz without issue.

Using the Built-in Terminal

Open Windows Terminal, navigate to the folder holding your archive with cd, then run:

tar -xvzf sitebackup.tar.gz

To extract to a specific path:

tar -xvzf sitebackup.tar.gz -C C:\Users\you\restored\

Using 7-Zip

  1. Download and install 7-Zip from its official site.
  2. Right-click the .tar.gz file and select 7-Zip > Extract Here.
  3. A .tar file appears in the same directory. Right-click it and again select 7-Zip > Extract Here.
  4. Your original files are now in that folder.

7-Zip processes .tar.gz in two steps because the formats are separate — first it strips gzip, then it unpacks TAR. For those who prefer working from the command line, the zip command reference covers the full flag set for similar archive operations.

Using WinRAR

  1. Right-click the .tar.gz archive and select Extract files…
  2. Choose your output folder in the dialog.
  3. Click OK.

WinRAR handles the two-step decompression internally, so only one action is needed.

How to Unzip tar.gz Files on macOS

macOS ships with tar. Open Terminal from Applications > Utilities, navigate to where your archive is, then run:

tar -xzvf sitebackup.tar.gz

The flag order differs slightly from Linux (-xzvf vs -xvzf), but both work on either system. To extract into a different directory:

tar -xzvf sitebackup.tar.gz -C /Users/you/restored/

On macOS, you can also double-click a .tar.gz file in Finder — Archive Utility opens automatically and extracts to the same directory.

Quick Reference: Unzip tar.gz by Operating System

OSToolCommand
Linuxtar (pre-installed)tar -xvzf file.tar.gz
Windows 10+tar (built-in)tar -xvzf file.tar.gz
Windows (any)7-Zip or WinRARRight-click menu
macOStar (pre-installed)tar -xzvf file.tar.gz

Preview Archive Contents Before Extracting

To list what’s inside a .tar.gz without extracting anything, use the -t flag:

tar -tzvf filename.tar.gz

This is worth doing with archives from unknown sources — you can verify file paths before anything lands on your disk.

Extract a Single File from a tar.gz Archive

If you only need one file out of a large archive, specify its exact path after the archive name:

tar -xzvf sitebackup.tar.gz path/to/specific-file.conf

The path must match what tar -t shows — not the path on your local system. For broader patterns, the --wildcards flag works on most Linux distributions, though macOS support varies by version. For bundling files with tar compress options, the same tool applies in reverse.

FAQs

What command extracts a tar.gz file on Linux?

Run tar -xvzf filename.tar.gz in your terminal. Add -C /path/to/folder to extract into a specific directory instead of the current one.

Can Windows open tar.gz files without extra software?

Yes. Windows 10 version 2004 and later includes a built-in tar utility. Run tar -xvzf file.tar.gz in Windows Terminal or Command Prompt.

What is the difference between .tar.gz and .tgz?

They are the same format. .tgz is a shortened alias for .tar.gz. Both extract with identical commands and tools across all operating systems.

How do I extract a tar.gz file to a specific directory?

Use the -C flag: tar -xvzf file.tar.gz -C /destination/path. The target directory must already exist before running the command.

How do I see what’s inside a tar.gz file without extracting?

Run tar -tzvf filename.tar.gz. This lists all files and directories inside the archive without writing anything to disk.

Willie has over 15 years of experience in Linux system administration and DevOps. After managing infrastructure for startups and enterprises alike, he founded Command Linux to share the practical knowledge he wished he had when starting out. He oversees content strategy and contributes guides on server management, automation, and security.