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

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 this is how the bitcoin bubble will burst such as 7-Zip offer a more user-friendly alternative. If the command line isn’t your thing, there are plenty of user-friendly tools available to unzip tar.gz files.

  1. This simplifies file management and reduces the risk of data loss during transfers.
  2. You can also add the verbose output option (-v) to provide detailed listings, including dates, securities/permissions, and more.
  3. Otherwise, keep reading to learn how to unzip .tar.gz files in Linux, macOS, and Windows.

This means it takes all the specified files and puts them together into one container. Similar to the previous error, this error occurs when an archive was saved as a .tar despite not being a .tar archive. While there are many tools to choose from, the most popular include 7-Zip and WinZip. While slightly different, they are quite lightweight and offer a much simpler alternative to using the command line.

How to Extract/Unzip .tar.gz Files: Step-by-Step Windows and Linux Guide

You can also select the files and directories you want to extract and the destination directory where you want to extract them. You can also choose the destination directory where you want to extract the files. The command will extract the files and directories in the current working directory, preserving the original permissions and ownership. To extract a tar.gz file using the tar command, you need to use the -x option, which tells tar to extract the files from the archive. You also need to use the -z option to indicate that the archive is compressed with gzip, and the -f option to specify the file name. In Linux, users have multiple ways to extract .tar.gz files – through the terminal and graphical file archivers.

How To Extract and Unzip .tar.gz Files (for Linux and Windows)

You need to specify the path to the directory where you want to extract the files after the -C option. Learn how to extract or unzip tar.gz files in Linux using the tar command and other tools. 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 will be 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.

You can also extract only specific files or directories from a tar.gz archive, by providing their names after the archive name. You need to use the exact names and paths as listed by the tar -t command. If you want to see the progress of the extraction, you can use the -v option, which makes the tar command more verbose and prints the names of the files being extracted. Note that this command will throw an error unless you specify the exact filename listed in the .tar file. As we’ll cover more in the next section, you can verify file names by listing contents with the tar -tf filename.tar.gz command. Again, the above commands will extract to the current working directory by default.

How to List Contents of .tar.gz File in Linux

You can use the -C option to extract to a different directory (in this case, /home/user/files). Most Linux distributions and macOS include built-in tools for zipping and unzipping .tar and .tar.gz files. While the tar utility is enough for most purposes, you’ll need the gzip utility to create .tar.gz files. Of course, that’s not to say .tar files are some kind of “lesser” format than .zip. Rather, they both accomplish the same task (file compression) in the same way.

Here are a few frequently asked questions we commonly hear from users working with .tar.gz files. This error occurs when trying to extract specific files or directories from a .tar.gz file using tar. But with .zip being the easier of the two to use, why use .tar in the first place? As we’ll see in the next section, .tar comes with a few extra features that make it the better compression format for certain files and applications.

Otherwise, keep reading to learn how to unzip .tar.gz files in Linux, macOS, and Windows. That means users can download and use it for free during a trial period. 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.

Some of the most popular archive managers for Linux are File Roller, Ark, Xarchiver, and PeaZip. They offer more features and options than the file managers, restaurant app builder such as creating, modifying, encrypting, and splitting archives. You can install them from your distribution’s package manager or software center.

7-Zip is a free and open-source tool with high compression ratios & supports a wide range of archive formats. 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. When you extract files from a .tar.gz archive, the checksum is automatically verified to detect & handle any potential data corruption. Like many archive and compression formats, .tar.gz is an effective way to save storage space and make it easier to send large amounts of data.

Knowing how to unzip a .tar.gz file allows users to extract and access the archives’ contents efficiently. This error occurs if you try to decompress a file without specifying a decompression utility, specifically -z for gzip. Some third-party tools also offer extended flexibility for converting between file types‌, saving more time if you want to change between compression formats. Like the tar utility, gzip also allows you to zip and unzip multiple files or entire directories at a time. For sending and storing, both .zip and .tar.gz files will allow you to send relatively large packages as a single file. However, there are some pretty major differences when it comes to accessing data within the files and the compression efficiency.

The command extracts files to a new directory called example1, which is located in the current directory. You can also add the verbose output option (-v) to provide detailed listings, including dates, securities/permissions, and more. You can also use –wildcards to extract all files with a certain extension or name.

You can just as easily unzip the resulting .tar.gz file with the decompress (-d) option. 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. You can specify one or more files or directories to include in the archive.

Extract Files to the Current Directory

If you specify a directory, tar will recursively archive all the files and subdirectories in that directory. This format is common in the Unix/Linux world and is widely used to create compressed archives. 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. If you want to keep the original file after compression, there are two options.

The extraction method is precisely the same for tar files that have compression, such as.tar.gz,.tar.bz2, and others. To unzip the .tar.gz files, you’ll need to use specific commands and tools depending on your operating system. Let’s explore the extraction process for both Linux & Windows platforms. Where commands have little (if any) room for typos or omissions, how to stake cardamo many common errors are the result of small mistakes, misspellings, or incorrect formats. Thankfully, unless you’re somehow missing your tar or gzip utility, most common errors are very easy to fix. Where most operating systems make it easy to extract and create .zip files, the same can’t really be said for .tar files — at least not in ways that are easy to notice.

However, there are also many third-party tools you can install for a more user-friendly experience. This command will extract (-x) the file (-f) specified (in this case, filename.tar.gz) to the current directory. Note that this command also works with other common compression formats such as .tar.bz2.