What is a .gz file?

A GZ file is a compressed file created using the gzip compression utility, which was originally created by two software developers as a replacement and improvement on Compress in UNIX . This utility is most commonly used on UNIX and Linux systems .

 

Gzip files contain useful information such as the original file name and timestamp, which is useful when the compressed file name has been truncated or the timestamp has been lost when the file was transferred. GZ compression is often used to compress certain elements of a web page to speed up page loading.

Files with the .gz file extension can only be launched by certain applications.

What is a .gz file?

Files with the .gz extension are called GNU compressed archives. .gz files are implemented using the encoding and compression standards developed by the GNU Project for the GZ compressed file format.

These compression specifications are based on the GNU ZIP compression algorithm, also known as GZIP compression technology. Users can select a single file or folder or even a group of files and folders and compress them into a GZ file.

Multiple GZ files can even be compressed into a single GZ file, or these GZ files can be placed in a directory that can then be compressed into a GZ file. The GZIP compression technology and the GZ compression format were developed for Linux systems, although there are some Microsoft Windows decompression applications implemented with support for decompressing and opening these GZ files.

 

Mac platform users can also install and use a number of Mac compatible decompression tools to open and view the archive contents of GZ files.

How to open .gz file?

How to open GZ files on Windows

There are a number of different ways to open and create archives on Windows, and the same goes for .GZ files. If you prefer commands, you can use the Command Prompt method. If you prefer a graphical user interface, you can use a free third-party application to access your GZ archives.

Extract GZ files on Windows using Terminal or Command Prompt

There is a command called tar that you can use in the Windows Terminal or Command Prompt to extract the contents of your GZ archive. This command is built into your operating system, so you don't need to install anything to use it.

Once you have the GZ file with you, use the following steps to extract its contents:

1. Open the Start menu, search for Command Prompt (or Terminal ) and click Run as administrator .

2. Click Yes in the prompt.

3. Type the following command replacing SOURCE with the source GZ file and DESTINATION with the destination directory and press Enter.

tar -xvzf PATHTOSOURCE -C PATHTODESTINATION

 

4. If all goes well, your extracted files should be available in the destination folder.

If your destination folder looks empty even after running the command successfully, it might be because you ran it without admin rights. Just open CMD with admin rights and it should be fine.

How to open GZ files using applications on Windows

If you want to unzip GZ files on Windows using an application, there are plenty of free alternatives. 7-Zip is a pretty good choice for this task, as it's easy, free, and open source.

Here's how you use this application to extract GZ archives on your PC:

1. Download and install the free 7-Zip tool on your PC.

2. Open the tool and navigate to your GZ file using the built-in file manager.

3. Select your GZ file in the list and click Extract in the top toolbar.

4. Select the destination folder in the Extract to section .

5. Adjust other options if desired and click OK.

6. Open the destination folder and you will have all the contents of the GZ file there.

Alternatively, you can use 7zip's context menu tools on Windows to extract .GZ files. Make sure to select this option during installation, then you can simply right-click to open GZ files with 7zip.

Unzip GZ files on macOS

Compressed file types like RAR require an unzipping app on macOS, but you don't need to do that for GZ.

You can open GZ files on your Mac without using any third-party tools. Again, you can use Terminal to extract files from GZ archives or the built-in macOS tool to unzip your files.

How to unzip GZ files on macOS using built-in tools

Just like a ZIP file, you can simply double-click your GZ archive and it will begin extracting the contents. You can do this from any Finder window on your Mac, and your extracted files will be available in a new folder in the same directory as the original GZ archive.

 

If that doesn't work for you, make sure you're opening your GZ file using the built-in unzip tool — the same tool used to compress files on macOS. If you're not sure what the default archive handler on your Mac is, just right-click your GZ archive and select Open With > Archive Utility to open the archive using the built-in tool.

Another way to open GZ archives 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 website). Both apps also support a number of other formats, including ZIP and RAR.

Using Terminal to Unzip GZ Files on macOS

Using Terminal, you can extract all the files inside your GZ archive with a single command. Your files will be placed in a new folder in the same directory as the original GZ file.

Here is how you use this method:

1. Click Launchpad in the Dock, search for Terminal , and click the utility.

2. Type the following command, replacing source.gz with the path to your GZ file and press Enter.

gunzip -k source.gz

3. Terminal will begin extracting files from your specified GZ archive.

How to unzip GZ files on Linux

If you are a Linux user looking to open GZ files, you can use a command in Terminal to extract all the files from your GZ archive. Some distributions also have built-in context menu options to extract .GZ files.

Open .GZ file in command line on Linux

Gzip is a command that allows you to uncompress the contents of a GZ archive on your Linux machine.

Here's how you use this command and start extracting your archives:

1. Open the Terminal application - any distribution has a Ctrl + Alt + T shortcut for this.

2. Type the following command, replacing SOURCE.GZ with the path to your actual GZ file and press Enter.

gzip -dk SOURCE.GZ

3. Your GZ archive will now be unpacked.

4. If your file is a .TAR.GZ file, you will need to use a different command to unpack your archive. Run the following command in Terminal to unpack the TAR.GZ file.

tar -xf SOURCE.tar.gz

How to open GZ files on Linux using built-in tools

There are multiple ways to unzip compressed files on Linux using the built-in graphical tool. Just like the macOS and Windows versions, it only takes a right-click. Here's how to unzip GZ files on Linux using the graphical interface:

 

  1. Using your favorite file manager, navigate to the folder containing the .GZ file
  2. Select the .GZ file and right click on it
  3. Select Extract here .
  4. The file(s) or folder(s) inside the GZ file will be extracted to the same folder you are in.

How to read Gzip compressed files in Linux command line

If you work with backend logs, you may have noticed that they are mostly compressed with the .gz extension. This is not surprising because compressing log files saves a lot of storage space and thus saves on storage costs.

But unlike regular text files where you can use cat to see all the contents of the file, use grep on it, or use less to read the contents without flooding your screen, compressed files cannot be used with regular Linux commands.

Don't worry, because you also have the powerful Z commands to handle them. These Z commands provide a 'Z' equivalent to the regular file manipulation commands.

So you get:

  • zcat instead of cat to view compressed files
  • zgrep instead of grep to search inside compressed files
  • zless instead of less, zmore instead of more , to view files in pages
  • zdiff instead of diff to see the difference between two compressed files

The best thing about using these Z commands is that you don't have to unzip the file. It works directly on the compressed files.

View compressed files with zcat

If you use cat, you can replace it with zcat. zcat is used exactly the same way you use cat. For example:

zcat logfile.gz

This command will display all the contents of logfile.gz without extracting it. Actually it temporarily extracts the file in /tmp but that's not the same as actual extraction, right?

You can use the regular less and more commands with zcat to see the output in pages:

zcat logfile.gz | less zcat logfile.gz | more

If you don't know if the file is compressed or not (i.e. the file doesn't have a .gz extension), you can use zcat with the -f option . This will display the contents of the file regardless of whether it is decompressed or not.

zcat -f logfile.gz

Read compressed files with zless and zmore

Similar to less and more , you can use zless and zmore to read the contents of a compressed file without extracting it. All the keyboard shortcuts for less and more work the same.

zless logfile.gz zmore logfile.gz

Search inside compressed files with zgrep

Grep is a powerful command. Zgrep is the Z version of grep, which allows you to search inside compressed files without extracting them.

You can use zgrep with all the usual grep options. For example:

zgrep -i keyword_search logfile.gz

Compare compressed files with zdiff

While this may not be useful for large log files, you can use zdiff to see the differences between compressed files, just like you would use the diff command.

zdiff logfile1.gz logfile2.gz

See also:

  • What is a DLL file? Why does my computer sometimes say a DLL file is missing?

You've just finished reading the article "What is a .gz file?" edited by the TipsMake team. We hope this article has provided you with many useful tech tips and tricks. You can search for similar articles on tips and guides. Thank you for reading and for following us regularly.

Close
Category

System

Windows XP

Windows Server 2012

Windows 8

Windows 7

Windows 10

Wifi tips

Virus Removal - Spyware

Speed ​​up the computer

Server

Security solution

Mail Server

LAN - WAN

Ghost - Install Win

Fix computer error

Configure Router Switch

Computer wallpaper

Computer security

Mac OS X

Mac OS System software

Mac OS Security

Mac OS Office application

Mac OS Email Management

Mac OS Data - File

Mac hardware

Hardware

USB - Flash Drive

Speaker headset

Printer

PC hardware

Network equipment

Laptop hardware

Computer components

Advice Computer

Game

PC game

Online game

Mobile Game

Pokemon GO

information

Technology story

Technology comments

Quiz technology

New technology

British talent technology

Attack the network

Artificial intelligence

Technology

Smart watches

Raspberry Pi

Linux

Camera

Basic knowledge

Banking services

SEO tips

Science

Strange story

Space Science

Scientific invention

Science Story

Science photo

Science and technology

Medicine

Health Care

Fun science

Environment

Discover science

Discover nature

Archeology

Life

Travel Experience

Tips

Raise up child

Make up

Life skills

Home Care

Entertainment

DIY Handmade

Cuisine

Christmas

Application

Web Email

Website - Blog

Web browser

Support Download - Upload

Software conversion

Social Network

Simulator software

Online payment

Office information

Music Software

Map and Positioning

Installation - Uninstall

Graphic design

Free - Discount

Email reader

Edit video

Edit photo

Compress and Decompress

Chat, Text, Call

Archive - Share

Electric

Water heater

Washing machine

Television

Machine tool

Fridge

Fans

Air conditioning

Program

Unix and Linux

SQL Server

SQL

Python

Programming C

PHP

NodeJS

MongoDB

jQuery

JavaScript

HTTP

HTML

Git

Database

Data structure and algorithm

CSS and CSS3

C ++

C #

AngularJS

Mobile

Wallpapers and Ringtones

Tricks application

Take and process photos

Storage - Sync

Security and Virus Removal

Personalized

Online Social Network

Map

Manage and edit Video

Data

Chat - Call - Text

Browser and Add-on

Basic setup