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. The extraction method is precisely the same for tar files that have compression, such as.tar.gz,.tar.bz2, and others. Again, the above command extracts to the current working directory by default. You can use the -C option to extract to a different directory (in this case, /home/user/files).
I had a lot of fun, three years ago or so, running a bunch of tests with different compression methods, and it was very enlightening to see how various files took to compression. Now the file “four” is extracted to a new directory called “bar.” If “bar” already exists, then “four” is placed inside the existing directory. If you have an existing tarball and want to add a new file into it, you don’t have to unarchive everything just to add a new file. Ubuntu Core is a minimalistic and immutable version explicitly designed for the Internet of Things (IoT) and embedded systems. The -C option is used to specify a different directory other than the current working directory. The name “Tar” stands for “Tape Archiver” because it was used to place data on storage tapes when tar was invented.
In other words, .zip files are a collection of compressed files, while .tar files are a compressed collection of files. On Windows, the easiest way to handle .tar files is to install the LGPL open source 7-Zip utility. Its name implies it’s a zip utility, but it also works with tar archives, and even provides commands for the cmd command-line interface. There are several ways to extract or unzip a tar.gz file in Linux, depending on the tool you have available or prefer to use.
While the command-line interface may seem intimidating at first, with practice it becomes an efficient and flexible tool. This compression is lossless – that means no data is lost during the compression process, and the original files can be fully restored upon extraction. The easiest way to open a tar.gz file on Windows is to install an excellent free utility called 7-Zip, which can handle tar.gz and just about any other file format. We’ve been recommending this app for years, and it’s one of the first things that we install whenever reinstalling Windows. You can open most .tar.gz files using the tar command built in to Linux, alloscomp : bitcoin mining calculator macOS, and Windows 10.
People new to the .tar format usually equate it to a .zip archive, but a tar archive is not compressed. Tar collected all the files into one package, but the files can be compressed with separate utilities. A GZ file is nothing but a file compressed using the gzip algorithm. You can use the official GNU gzip utility to extract the content of the compressed archive file. If the file you’re looking at is a TAR.GZ, using either tar or 7-Zip to extract the file will be a much simpler choice.
Using the command line (cmd)
A tar.gz file is a compressed archive format commonly used in Linux systems to combine multiple files and directories into a single file while reducing their size. It combines the tar utility for archiving and the gzip utility for compression. Knowing how to extract or unzip a tar.gz file allows users to access and manipulate the archives’ contents efficiently.
How to Extract or Unzip a tar.gz File in Linux
If you’re not comfortable with the terminal or command line, third-party tools such as 7-Zip offer a more user-friendly alternative. 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.
Zip and unzip .tar and .tar.gz in Linux with gzip
As a result, we recommend sticking to free (but trustworthy) tools or simply using the command line. The tar format is just a format, and it’s an open format, so it can be created by more than just one tool. If the directory does not exist, tar will create it automatically. Ubuntu versions are usually named using an alliterative adjective and an animal name, both starting with the same letter. Canonical released its first official version of the OS, Ubuntu 4.10, codenamed ‘Warty Warthog’ in October 2004. Canonical released its first official version of the OS, Ubuntu 4.10, codenamed ‘Warty Warthog’ in October 2004.
On Linux, BSD, Illumos, and even Mac OS, the tar command is already installed for you. Snaps were developed by Canonical, the company behind Ubuntu, to package and distribute software focusing on security, sandboxing, and ease of installation and updates. They were officially introduced in Ubuntu 16.04 LTS, released in April 2016.
The aforementioned command will extract the archive.tar.gz file to the /Downloads folder. It also integrates with the Windows Explorer context menu, which enables users to create and extract archives directly from the right-click menu. You can easily extract .tar.gz files using third-party tools like 7 zip and Winrar on the Windows system. You can notice in the above image that the archive files are extracted in the same working directory. But it does not compress the data, which results in a larger file size compared to compressed formats. You can easily unzip the resulting .tar.gz file with the decompress (-d) option.
To list the contents of a tar.gz file without extracting it, you can use the -t option with the tar command. The -t stands for ‘list’ which instructs the tar command to display the contents. On the other hand, Windows users can rely on third-party file archiver tools like 7-zip or WinRAR to effortlessly extract files. Note that this command will throw an error unless you specify the exact filename listed in the .tar file. As we cover more in the next section, you can verify file names by listing contents with the tar -tf filename.tar.gz command. A “.tar” file is a collection of files compressed into a single file or archive.
Is .tar.gz more efficient than .zip?
- 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.
- File compression is a great way to save storage on a computer.
- Note that this command will throw an error unless you specify the exact filename listed in the .tar file.
- 7-Zip is a free and open-source tool with high compression ratios & supports a wide range of archive formats.
Ubuntu LTS (Long-Term Support) versions, known for their stability and extended support periods, are typically released every two years in April. These are popular for organizations and users who require a reliable and well-supported Ubuntu operating system. Most Linux distributions come with the tar command pre-installed by default. Many of the downloadable Linux/Unix files found on the internet are compressed using a tar.gz format. Therefore, knowing how to open or untar tar.gz files is very useful.
You need to specify the path to the directory where you want to extract the files after the -C option. When you want to share multiple files with someone else, compressing those files into a single TAR archive is the most efficient solution. Apart from occupying less space on your system storage, compressed archives utilize less server bandwidth when downloaded by multiple users. 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.