Most of us are familiar with ZIP files, and those who’ve used Windows would recognize RAR files as well. Both of those are popular archiving formats, frequently used to compress files and folders, and easily send them out without compromising their integrity.
Naturally, .zip and .rar are not the only archives available. If you use Mac or Linux, eventually you’ll encounter .z or .gz files as well.
What is a GZ file? The GZ (or GZIP) archive format was created by Jean-loup Gailly and Mark Adler, two software developers, back in 1992 who used the GNU Gzip compression algorithm to improve on the default compression process in UNIX. That’s why you most often see .gz files in macOS and Linux systems.
A unique feature of .gz files is that they can only contain one item each (unlike .zip or .rar). To combine multiple files under .gz format, you need to first use an archive utility like TAR, which would create a special .tar.gz or .tgz file format.
Let’s see why you might want to use .gz files, how to open gz files on Mac, and how to extract .gz archives as well as create your own.
Why Use GZ Archives?
GZ or GZIP is still a widely used compression algorithm because it helps reduce the size of a file considerably while protecting its integrity. Importantly, GZIP compression doesn’t strip out the original file name, ownership, or timestamp. The latter is especially handy when working with files that can easily get truncated in transfer.
Today, you also often see .gz files being used in web development to compress web elements and make webpages load faster.
So how do you create and extract .gz archives on your Mac? You have a few options to do that.
How to open GZ files on Mac
While Windows users have to install additional apps and extensions to open GZ files, Mac users can do so by default.
Archive Utility, for example, which is Mac’s default archiving app (with no user interface) can easily extract .gz archives at any time. To do so, just double-click on the .gz file or right-click, go to Open With, and select Archive Utility.
Unfortunately, while Archive Utility can unzip GZ files, it can’t zip them back into archives. For that, you need to either use Terminal or third-party software.
How to unzip GZ files with Terminal
Since .gz file format was originally created to make archiving better on UNIX systems, it can also be controlled by Mac’s command line — Terminal.
Terminal is very powerful, letting you do any action on your Mac without the graphical user interface. But it’s also quite unforgiving, since it’s very easy to do something very wrong. That’s why most people try to avoid it.
To safely extract .gz files, you can use Terminal’s gzip or gunzip commands. But, first, make sure that your terminal state is in the same folder and the files about to be zipped. You can use the ls -la command to print the files in the current folder and then navigate inside folders with the cd command or step back with the cd - command.
Alternatively, you can just also drag and drop your file onto the Terminal’s window.
To unzip GZ files, use: gzip -d file.gz (where file.gz is the path to your file). For simpler syntax, you can also use gunzip to replace gzip -d, so type: gunzip file.gz
These commands will also remove the original file. To unzip GZ and keep the original file, use: gzip -dk file.gz
If you’re actually trying to extract a folder archive like .tar.gz, the Terminal command is a bit different: tar -xf file.tar.gz
All of the commands above will extract files in the same directory as the original archive. You can also now see why most people avoid using Terminal, it works like magic but, at the same time, it’s hard to understand how. Luckily, there are a few more powerful and user-friendly options you can turn to.
How to extract .gz archives with third-party apps
If you’re looking for fast and easy options to unzip GZ files, you should start with Archiver.
Archiver is a lightweight archiving utility that is blazing fast and supports all the archiving formats you’ll ever meet in your life. Its interface is so intuitive that you barely have to do anything, just follow a few prompts to either create or unpack an archive at any time.
Moreover, you can extract files out of the same archived folder selectively and preview them with Quick Look. You can also set passwords, combine a few archives together, or split large archives into equal parts.
To unzip GZ file with Archiver:
- Launch Archiver
- Drag and drop your archive onto the app
- Use Space to preview your file in Quick Look
- Click Extract
Similarly, to create an archive like .tar.gz, you can use the Convert feature in Archiver and choose TAR.GZ among the options. Then click Convert.
How to extract a specific file from a tar archive?
BetterZip is another powerful archive manager. It lets you browse and manage archives without even unarchiving them in the first place! So you can preview, rename, edit, and delete files right within the app.
In addition, BetterZip is a breeze to zip and extract more than 30 archive formats, install passwords, and even automate any archiving functionality with AppleScript.
To extract a specific file from a gzip-compressed archive with BetterZip:
- Launch BetterZip
- Drag and drop your file onto the app
- Preview with Space to launch Quick Look, if needed
- Click Extract in the top menu
As you can see, there’s no shortage of ways to create and open GZ files. For the most basic functionality, the default Archive Utility will suffice. For the most advanced users, learning a few Terminal commands could be helpful. But most people should probably try Archiver as the easiest way to unarchive files or BetterZip as the most flexible archiving solution on the market.
Best of all, Archiver and BetterZip are both available to you absolutely free for seven days through the trial of Setapp, a platform with more than 210 best-in-class Mac apps that cover any app category possible, from managing your daily tasks (2Do) to creating text templates for repeating messages (Rocket Typist). Try every Setapp app at no cost today and download dozens of wonderful apps to skyrocket your productivity.