How to Gunzip Extract a ‘ gz’ File in Linux

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. 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.

Like the tar utility, gzip also allows you to zip and unzip multiple files or entire directories at a time. 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. Knowing how to unzip a .tar.gz file allows users to extract and access the archives’ contents efficiently. Note that this command will throw an error unless you specify the exact filename listed in the .tar file.

A GUI is more suitable for beginners than a command-line tool. Since GZ files are compressed formats, after all, it goes without saying that extracting them requires a utility that can perform this task. Likewise, you can even prefer speed how to buy mana over quality while uncompressing a file or directory. In this case, use the “-1” option followed by the filename that is to be decompressed. If there’s a compressed file you need to open, once again right-click that archive in Files.

Note that this command also works with other common compression formats such as .tar.bz2. 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.

  1. Gzip is the compression algorithm, reducing the file size while still keeping the original file mode, ownership, and time stamps.
  2. Since after all, it’s only after decompression that the files are of any use or not.
  3. Short for “Tape ARchive,” the name “TAR” is a throwback to when files were stored on magnetic tape drives.
  4. You’ll need to know how to open GZ files in Linux at some point.

As we’ll see later, different compression utilities may require different methods for extracting and unzipping files. Though we’ll mostly focus on .tar.gz files, check out the end of the article for some quick tips on extracting .tar files in other formats. The “gunzip” command is one of the best algorithms used by Linux enthusiasts for file decompression.

As we have seen over the course of this article, xz files are nothing special. Most of the newer graphical distros like Ubuntu and Linux Mint come with built in tools to decompress files using a GUI. The “gunzip” command provides a “-l” flag which displays the information about the compressed file without necessitating its decompression. This information might be the size of the original file, the size of a compressed file, the name of the actual file, and the ratio of compression. 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: Unrecognized archive format

This error usually occurs when a .tar has been saved as a .gz despite having never been compressed using the gzip utility. Executing this command will effectively decompress the specified files, creating new decompressed versions while retaining the original compressed files intact. To confirm the change, display all the files in the current directory. This command will extract (-x) the file (-f) specified (in this case, filename.tar.gz) to the current directory.

What Are .tar and .tar.gz Files?

You’ll see a number of options, including Open With Archive Manager, Extract Here, and Extract to. If you need to compress a file, once again use the command gzip, but without any options other than the file you want to bitcoin price hits $58k compress. If you’re using a Linux PC, you’ll need to open a file or folder that’s been compressed to take less disk space from time to time. This is done to save room or to let you upload or download a file faster.

Is .tar.gz The Same As .zip?

This will decompress the “singleFile.gz” file and restore the original file named “singleFile”. To verify if your file is decompressed, simply execute the “ls” command. If you want to work with gzip files, the steps above should help you to compress and decompress them on a Linux PC. This error occurs when trying to extract specific files or directories from a .tar.gz file using tar. You can just as easily unzip the resulting .tar.gz file with the decompress (-d) option.

If you have an error which is not present in the article, or if you know a better solution, please help us to improve this guide. That being the case, we would like to recommend you try out WinZip, the world’s best file archiver and unzipper. However, while tools like 7-Zip are free, many more “robust” solutions are only available for a price after a trial period.

This guide covered various commands for decompressing files and directories using the “gunzip” utility that are compressed by the “gzip” command. Though both .zip and .tar.gz archive and compress files, they do so in different ways. In other words, .zip is a collection of compressed files, while .tar.gz is a compressed collection of files. Where .zip files consist of many individually compressed files, .tar files are compressed as a single package, leaving its files uncompressed.

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. You can use the -C option to extract to a different directory (in this case, /home/user/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. Sometimes, you may need to decompress a file while a decompressed file of the same name already exists in the directory.

This will display comprehensive information about the “ubuntuMintFile” file. Once you choose the directory, click the lloyd’s launches new cryptocurrency wallet insurance solution for coincover Select button in the top right corner. This is simpler than you think, so without further ado, let’s get started.

The flag or option comes with a hyphen after the “gunzip” command. 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. 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.

As a result, we recommend sticking to free (but trustworthy) tools or simply using the command line. 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. Once you’ve followed these steps, the file’s content should now be extracted in the location of your choosing.

In other words, .zip files are a collection of compressed files, while .tar files are a compressed collection of files. If you have been on Linux for sometime you might have come across another file extension .tar.gz. This overcomes the big limitation of standard gz, and allows for compression of entire folders. It’s important to note, the gzip algorithm is designed to compress a single file. If you need to bundle multiple files together, or an entire directory structure, you’ll use both tar and gz.