Linux on Windows

How to quickly extract .tar.gz files on Windows 10

If you come across a .tar.gz, .tgz, or .gz file, you can use these steps to use tar command line tool to extract its content on Windows 10 using Ubuntu.

Extracting .tar.gz on Windows 10

A file using .tar.gz format is a file that has been created using Unix-based archival application tar and then compressed using gzip compression. These files are often referred as “tarballs,” and while you can find them with a double extension (.tar.gz), the extension can also be shortened to .tgz or .gz.

Usually, tar files are commonly used by Ubuntu and macOS users for data archival and backups, but sometimes Windows 10 users may also come across these types of files and may need to extract its content.

While you can use a number of third-party applications like 7-Zip and PeaZip, sometimes these applications don’t play well with files created on another platform, and they’re slow to uncompressed a large number of files. However, Windows 10 includes a new subsystem for Linux that brings native support for Ubuntu, Fedora, and SUSE, and therefore you can also access many Linux tools, including tar to quickly extract content from tarballs.

In this guide, you’ll learn the steps to use native tar commands on Windows 10 using Ubuntu to extract the content of a .tar.gz file.

How to extract .tar.gz, .tgz, or .gz tarballs with Windows Subsystem for Linux

In order to use tar on Windows 10, you must have installed Ubuntu, you can refer to this guide for step-by-step instructions if you’re running the Creators Update or a previous release of Windows 10. However, starting with the Fall Creators Update, you can simply enable the Windows Subsystem for Linux using the Windows Features experience, and then install Ubuntu from the Windows Store.

Once you have Ubuntu installed on Windows 10, use the following steps to extract a .tar.gz file:

Important: Starting with version 1803 (Redstone 4), the tar command tool comes built into Windows 10, which means that the use of Windows Subsystem for Linux is no longer required to use tool.
  1. Open Start.

  2. Search for Ubuntu and click the result.

  3. Type the following command to extract the content of .tar.gz file and press Enter:

    sudo tar -xvzf /mnt/c/PATH/TO/TAR-FILE/Desktop/FILE-NAME.tar.gz -C /mnt/c/PATH/TO/DESTINATION/FOLDER
    Tar command on Windows 10
    Tar command on Windows 10
    Quick Tip: If it’s only a .tar file, you can use the same command described above, but do not include the z argument.

In the above command, we type sudo to run the application as an administrator, tar to call the application, and then we feed it some arguments, including:

  • x — instructs tar that you want to extract content.
  • v — verbose. This is an optional argument to display the extraction process. Otherwise, you’ll only see blinking cursor until the process is complete.
  • z — tells tar to uncompressed the content of a .tar.gz file with gzip.
  • f — instructs tar the name of the file you’re about to extract.

Then you need to specified the path of the tarball file you want to extract. You’ll notice that the path starts /mnt/c/, instead of c:\, and this is because we’re actually working in the Linux world.

-C — (hyphen and capital C) is used to tell tar to change folders. When you’re executing a command, you start in the source folder, and then you need to specify the destination folder, which is the path we specified to complete the command. You can extract the files to any folder you want, but remember to start the path with /mnt/ followed by the Windows path.

It’s very important that you pay attention to uppercase and lowercase while typing a command in Linux as Desktop is not the same as desktop.

How to extract .tar.gz, .tgz, or .gz tarballs without Windows Subsystem for Linux

Starting with version 1803, Windows 10 is adding native support for tar, which means that now you can extract .tar.gz, .tgz, .gz as well as .zip files without the need to install the Windows Subsystem for Linux, just use these step:

  1. Open Start.

  2. Search for Command Prompt, right-click the first result and select Run as administrator.

  3. Type the following command to use tar to extract the files and press Enter:

    Quick Tip: Because you’re using tar on Windows 10, you don’t need to specified the path as if you were running Linux. You can simply use the path format use by Windows.

Once you’ve completed the steps, after a few moments you will have all the files and folder extracted to the destination path you specified.

It should be noted that it’s assumed that you’re extracting a tarball that was created on another system, therefore we’re skipping some arguments usually necessary to preserve permissions, which in Windows 10 are not really necessary just to access the files. 

Also, in this guide, we’re looking at the basic steps to perform a specific task, if you’re not a Linux user, there is a lot more to learn about tar. If you want to learn more about this tool, in the Ubuntu console type tar --help.

Update January 30, 2018: This guide has been updated to reflect that you can also use tar without having to install the Linux layer on Windows 10.