How to Zip and Unzip or Extract TAR and TAR GZ Files

how to untar tar gz file

Short for “Tape ARchive,” the name “TAR” is a throwback to when files were stored on magnetic tape drives. In Linux, users have multiple ways to extract .tar.gz files – through the terminal and graphical file archivers. The extraction method is precisely the same for tar files that have compression, such as.tar.gz,.tar.bz2, and others. You can use Tar (available on Linux) to extract files from previously created archives, to store extra files, and even to update files that were previously stored. If you use any open source software and use Linux, you’ll definitely need to untar tar.gz files at some point. (Tar is available on Linux.) If you want to extract or untar tar.gz files from your Linux-based VPS using command line options, there are several ways you can do this.

Technical details aside, all you need to remember is that .zip files are more accessible but less space-efficient, while .tar files are less accessible but more space-efficient. As a result, one isn’t necessarily better than the other — it’s all a matter of application. 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. 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. A “.tar” file is a collection of files compressed into a single file or archive.

It may sound like a silly mistake, but it’s surprisingly common in situations where users directly rename files and their extensions (such as .tar and .gz) in the process. You can create your own compressed .tar files using compression utilities such as gzip. Gzip is one of the most popular and available options, especially since it comes built in to most Linux distributions and macOS. Tar is an archiving program designed to store multiple files in a single file (an archive), and to manipulate such archives.

how to untar tar gz file

Extract Files to the Specific Directory

If you find this article helpful or have additional ideas, please use the comment box below. For more information and to schedule a live demo, contact a hosting expert from Kinsta today. To access the Windows command line, search for “command prompt” or “cmd” in the search bar. Right-click the first result and select the “Run as administrator” option.

Using the tar Utility

The .tar portion of the file extension stands for tape archive, and is the reason that both of these file types are called tar files. Tar special circumstances of the inverse of cosine function files date all the way back to 1979 when the tar command was created to allow system administrators to archive files onto tape. Forty years later we are still using the tar command to extract tar files on to our hard drives. Someone somewhere is probably still using tar with tape. Though both .zip and .tar.gz archive and compress files, they do so in different ways.

On Linux, there are multiple ways to unzip compressed archives. The .tar section of the file extension stands for “tape archive”. Even though most of us have hard drives instead of magnetic tape, we still call them tar files. 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.

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. Then we’ll jump into the step-by-step process of unzipping on both Linux and Windows platforms. Most Linux distributions ship with a preinstalled archive manager. Decompressing TAR and TAR.GZ files is only a matter of few clicks using the GUI. Similarly, you can unzip specific directories from the archive as well.

You may also be interested in learning about the best WinZip alternatives to compress files. We can see that the Ukulele Songs directory contains directories called Random Songs, Ramones and Possibles. 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. Use the –exclude flag to specify the names of the files that you don’t want to extract. You can combine both steps into a single command as well. The c, v, z, and f flags used in the aforementioned command stand for Create, Verbose, gzip, and Filename.

What’s the difference between .tar and .tar.gz files?

Creating archives is an important step when you’re backing up your Linux file system. This ensures that your backup remains unaffected and the files don’t corrupt if anything breaks on your system. This example uses example1.tar.gz in the Home directory. The output shows a newly created archive example1.tar.gz. Snaps were developed by Canonical, the company behind Ubuntu, to package and distribute software focusing on security, sandboxing, and ease of installation and updates.

  1. So far we’ve just taken a leap of faith and extracted the files sight unseen.
  2. You can combine both steps into a single command as well.
  3. This error usually occurs when a .tar has been saved as a .gz despite having never been compressed using the gzip utility.
  4. However, while tools like 7-Zip are free, many more “robust” solutions are only available for a price after a trial period.

If you want to unzip the files to a different folder, click on the Extract To option. Choose the appropriate location and click Select to extract the file to that location. For TAR.GZ files, you will have to unzip the compressed archive to TAR, and then further extract the TAR file using 7-Zip. The -so and -si flags denote Standard Output and Standard Input. The first part of the command writes the archive.tar file to the standard output.

Note that the path is wrapped in quotation marks because there are spaces in the path. Notice that we don’t need to use the -z option to list the files. We only need to add the -z option when we’re extracting files from a .tar.gz file. Likewise, we don’t need the -j option to list the files in a tar.bz2 file. If we list the files in the Download directory we will see that another directory called Guitar Songs has been created. Files that have a .tar.gz or a .tar.bz2 extension are compressed archive files.

Saving Storage and Bandwidth on Linux

They were officially introduced in Ubuntu 16.04 LTS, released in April 2016. The -C option is used to specify a different directory other than the current working directory. 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. Similar to the previous error, this error occurs when an archive was saved as a .tar despite not being a .tar archive. You can also use –wildcards to extract all files with a certain extension or name. Otherwise, keep reading to learn how to unzip .tar.gz files in Linux, macOS, and Windows.

A GUI is more suitable for beginners than a command-line tool. 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. 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.

Gzip compression uses a checksum to make sure data integrity. When you extract files from a .tar.gz archive, the checksum is automatically verified to detect & handle any potential data corruption. 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.

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 is because most versions of tar allow both gnu and bsd style options (simplistically, gnu requires a hyphen, bsd doesn’t). As the files are extracted, they are listed in the terminal window. One file is called ukulele_songs.tar.gz , the other is called guitar_songs.tar.bz2 . File compression is a great way to save storage on a computer. If you’re familiar with packages in Linux, you may have come across a TAR or a TAR.GZ file.

Önceki Yazılar:

Sonraki Yazılar: