Skip to main content
Cryptocurrency exchange

How to Unzip a gz File on Linux: A Step-by-Step Tutorial

By September 30, 2022September 5th, 2024No Comments

how to unzip .gz file

Whether you prefer the command-line power of the tar command or the visual simplicity of a graphical file manager, both methods are effective and straightforward. Once you’ve found the .gz file, right-click on it to reveal a context menu. Selecting either of these options will initiate the unzipping process. If you’re coming across one for the first time, use one of the methods above to extract the contents from your GZ archive.

What is a ZIP File?

  1. Gzip is the most popular file compression utility for Linux systems which can be used alone to compress individual files.
  2. If you want to unzip the file to a specific directory, choose the “Extract to” option from the context menu.
  3. That’s because, by default, gzip creates the archive file and deletes the original file.
  4. This is important, as an increase in web page loading can reduce bounce rate (visitors leaving your site) by up to 32%.
  5. But using WinZip, you can instead create ZIP files that share the same benefits as the GZ file format with better accessibility.

We have our new_archive.tar.gz file and need to extract a file named myfile from it. In the example below, use the following command to see the decompressed file. The unique strings are allocated a unique ID token by virtue of their position in the tree. The tokens are used to replace the strings in the data and, because the tokens are smaller than the data they replaced, the file is compressed. Substituting the tokens for the original strings re-inflates the data back to its uncompressed state.

On the other hand, Zip compresses each file before adding them to an archive, which results in a bigger archive file size. However, having an archive compressed makes it more difficult to extract individual files without uncompressing the whole tarball first. We can create an archive file that contains a directory tree and all of its files, but we need to bring another command into play.

Using Gzip/Gunzip to Create or Unzip GZ FIles

GZ and TGZ files are considered file compression and archiving standards for Linux systems. In this article, we will learn what Gzip and Tar utilities are and how to create and unzip GZ and TGZ/TAR.GZ files in Linux. This time, we can see that gzip has deleted the archive file after extracting the original file.

how to unzip .gz file

Tar and Gzip are popular Linux system utilities for file compression and archiving. Although both tools are usually used together, Tar and Gzip perform different tasks. The original file, a spreadsheet called “calc-sheet.ods” is 11 KB,  and the compressed file—also known as an archive file—is 9.3 KB. Note that the name of the archive file is the name of the original file with “.gz” appended to it. This experience taught me the importance of understanding how to unzip GZ files as a Linux user. With the right knowledge and tools, unzipping GZ files can be a simple and straightforward process.

Method 1

This command will extract the contents of all .tar.gz files in the current directory. Much like a ZIP file, the GZ file format is used for file compression. And with the GZ file extension, it’s possible to store single files. You can open GZ files with the GNU zip (gzip) compression utility. You can Untar Gzip-compressed Tar archives using the -x (extract) flag the Tar command provides.

If you know in advance that you’re happy to have the file in the directory overwritten by the file from the archive, use the -f (force) option. If you need the original file you can retrieve it from the archive file. But if you prefer to retain the original file, you can use the -k (keep) option.

A.The command to unzip gz files on Linux is “gzip -d file.gz”. Extracting .GZ files in Linux is a skill that can significantly streamline your work and data management. With the techniques outlined in this guide, extracting .GZ files should no longer be a daunting task. As you continue to work with Linux, these skills will not only help you manage compressed files better but also boost your confidence in handling various file formats.

Compressing Directory Trees

Another way to open a GZ archive in macOS is to use free apps. There are popular options, like The Unarchiver or Keka (paid on the macOS App Store but free on the developer’s site). Both apps support several other formats as well, including ZIP and RAR. We are keeping the original files using the -k flag and can see the percentage reduction and the names of the files processed as the command runs by using the -v option.

Three new GZ files will be created in the directory due to the command above. The -k flag might be unavailable in some cases, so we will need to use the -c option to keep the original file. Don’t mistake compression for encryption or any form of protection. Compressing a file doesn’t give it any security or enhanced privacy. Anyone with access to your file can use gzip to decompress it.

You can choose to prioritize the speed of creation of the archive or the degree of compression. You do this by providing a number as an option, from -1 through top -9. The -1 option gives the fastest speed at the sacrifice of compression and -9 gives the highest compression at the sacrifice of what is the optimal inventory turnover ratio speed.

how to unzip .gz file

Choosing the Destination Directory

But even with a fairly small file, there’s likely to be some reduction in size. The gzip data compression tool was written in the early 1990s, and it’s still found in every Linux distribution. There are other compression tools available, but no matter which Linux computer you find yourself needing to work on, you’ll find gzip on it. So if you know how to use gzip, you’re good to go without the need to install anything. The gzip command is the easiest way to unzip a GZ file, and it’s built into most Linux distributions.

However, the GZ file format is often combined with TAR archives to archive multiple files. The tar command is used to create and unzip the TGZ files on a Linux system. You can choose to unzip the whole archive or extract only the selected files or directories. Below we will learn how to unzip TAR.GZ files from the command line using different flags. Tar supports multiple compression methods, the most common of them are the Gzip/Gunzip and Bzip2/Bunzip2 compression utilities. Using Tar together with Gzip for file compression has become the best file archiving solution for Linux.

The gunzip command is another way to unzip a GZ file, and it’s also included in most Linux distributions. Now that we know what GZ files are and why they are used let’s walk through the steps for unzipping them. There are a few different methods you can use, so we’ll cover a few options and when to use them. This command will extract the contents of filename.tar.gz and will preserve the original file permissions. Alternatively, you can use 7zip’s context menu tools on Windows to unzip a .GZ files.

The most commonly used programs to open GZ files are WinZip or the native GZIP software for Unix and Linux users. Many people are scouring the web in search of answers to their questions related to the GZ file format. With a file as small as this, we didn’t see any significant difference in speed of execution, but there was a small difference in compression.

author avatar
designer