27 MayHow to Extract or Unzip tar GZ File in Linux using Command Line

Since .tar.gz compresses multiple files all at once, it can take advantage of similarities between individual files to save on space. Generally speaking, a collection of files archived and compressed as a .tar.gz are more space-efficient (i.e., smaller) than the same collection compressed as a .zip. With the command prompt open, use the appropriate commands to change the current working directory (cd) to the location of the .tar.gz file you want to unzip. Alternatively, you can also specify a source and destination file path when using the tar utility. Unlike Windows’ convenient graphical user interface (GUI) for unzipping .zip files, you need to use the tar utility through the command line. However, there are also many third-party tools you can install for a more user-friendly experience.

Note that the path is wrapped in quotation marks because there are spaces in the path. If we want to extract the files to a location other than the current directory, we can specify a target directory using the -C (specified directory) option. If we list the files in the Download directory we will see that another directory called Guitar Songs has been created.

Compress Multiple Directories or Files at Once

Gzip is also more common, with some stripped-down Linux systems including gzip support by default, but not bzip2 support. In general, though, gzip and bzip2 are practically the same thing, and both will work similarly. You can easily unzip the resulting .tar.gz file with the decompress (-d) option. You can also add the verbose output option (-v) to provide detailed listings, including dates, securities/permissions, and more.

Also, its trial version does not have time limitations, and users can still use it even after the trial period has expired, with occasional reminders to purchase the license. These files can be used in incremental backup strategies – where only new or modified files are added to the archive. It just bundles files & directories together while preserving their file structure and metadata. This means it takes all the specified files and puts them together into one container.

Once you have an archive, you can extract it with the tar command. The following command will extract the contents of archive.tar.gz to the current directory. You can open most .tar.gz files using the tar command built in to Linux, macOS, and Windows 10. If you’re not comfortable with the terminal or command line, third-party tools such as 7-Zip offer a more user-friendly alternative.

Unzip Files with gunzip

If the command line isn’t your thing, there are plenty of user-friendly tools available to unzip tar.gz files. If you want to keep the original file after compression, there are two options. The first is the -k option, and the other uses the -c option to output the compressed file to a different file, preserving the original. Thankfully, you don’t need to be a 1960s computer technician to use and extract .tar files – nor do modern .tar files even have anything to do with old computers. This compression is lossless – that means no data is lost during the compression process, and the original files can be fully restored upon extraction. This format is common in the Unix/Linux world and is widely used to create compressed archives.

It’ll also compress every other directory inside a directory you specify — in other words, it works recursively. In this example, the user tried to extract the file titled “FILE” from filename.tar.gz. However, tar was unable to find FILE within .tar.gz, meaning 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 separate entities.

The -v option makes the tar command more verbose and prints the details of each file, such as permissions, owner, size, and modification date. If you only want to see the file names, you can omit the -v option. The following article will help you to extract (unpack) and uncompress (untar) – tar, tar.gz and tar.bz2 files from the Linux what net sales means command line. Files that have a .tar.gz or a .tar.bz2 extension are compressed archive files. A file with just a .tar extension is uncompressed, but those will be very rare. If the file is a bzip2-compressed file, replace the “z” in the above commands with a “j”.

gzip: stdin: not in gzip format

The tar command will work happily with both types of file, so it doesn’t matter which compression method was used — and it should be available everywhere you have a Bash shell. Though gzip is the most common compression utility, it’s 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), among many others. 7-Zip is a free and open-source tool with high compression ratios & supports a wide range of archive formats.

How to Unzip or Extract tar.gz Files on Windows

But with .zip being the easier of the two to use, why use .tar in the first place? The next section shows how .tar comes with a few extra features that make it the better compression format for certain files and applications. Compressing and extracting these files, however, isn’t always intuitive. This article provides detailed guides to unzip .tar.gz files in Linux and Windows, as well as a few helpful tips and tricks. Whether you prefer command-line tools or graphical file archivers, the extraction process is pretty simple. You can notice in the above image that the archive files are extracted in the same working directory.

  1. Where commands have little (if any) room for typos or omissions, many common errors are the result of small mistakes, misspellings, or incorrect formats.
  2. It’s easy to get confused when navigating between .tar, .tar.gz, and .gz – not to mention zipping and unzipping them.
  3. This compression is lossless – that means no data is lost during the compression process, and the original files can be fully restored upon extraction.
  4. If you plan to distribute and store .tar.gz files on your website, Kinsta’s managed hosting services can help make the most of your space.
  5. Thankfully, you don’t need to be a 1960s computer technician to use and extract .tar files – nor do modern .tar files even have anything to do with old computers.

.tar.gz Files

Right-click the first result and select the “Run as administrator” option. This simplifies file management and reduces the risk of data loss during transfers. And of course this is possible with the Linux tar command, but firstly you need to check what is there inside the tarball without unpacking it. A Linux distro that feels like home for Windows users, with all the power and none of the hassle. Once you choose the directory, click the Select button in the top right corner.

You’ll encounter them frequently while using a Linux distribution like Ubuntu or even while using the terminal on macOS. Here’s how to extract — or untar — the contents of a tar file, also known as a tarball. The GNU tar command included with Linux distributions has integrated compression. It can create a .tar archive and then compress it with gzip or bzip2 compression in a single command.

This reduces a TAR file’s file size, making it even easier to store and share. Primarily, users compress TAR files using Gzip compression, turning them into .TGZ or .TAR.GZ files. In Linux, users have multiple ways to extract .tar.gz files – through the terminal and graphical file archivers. To extract a tar.gz file using an archive manager, you need to open the file with the archive manager and then click on the Extract button.

It offers AES-256 encryption to protect sensitive data within archives. Users can utilize the 7-zip command-line interface for automated & scripted extraction tasks. Most file managers, such as Nautilus, Dolphin, or Thunar, support extracting tar.gz files by right-clicking on the file and choosing the Extract option from the context menu. You can also choose the destination directory where you want to extract the files. You can also extract only specific files or directories from a tar.gz archive, by providing their names after the archive name.

Comments are closed.