Share your love
Extract Tar Gz Files in Linux with 1 Easy Command

This tutorial intends to teach you how to Extract Tar Gz Files in Linux Command Line. In the Linux operating system, a tar.gz file is a compressed archive format. It is used to compress multiple files and directories into a single file. It has two parts: Tar and Gz which means:
Tar: This is a tool that creates archive files which are known as tarballs. It will collect files into a single file.
Gz: It is the compression tool that reduces the file size. It will compress the tar archive into a tar.gz or gzipped tarball file.
You can now follow the guide steps on the Orcacore website to Extract Tar Gz Files in Linux Command Line.
Table of Contents
Purpose of Using Tar GZ Files in Linux
The purpose of using tar.gz files in Linux devices in two parts:
Bundle Files and Directories in Linux: As we said, Tar will collect multiple files and directories into a single file. This will help you to manage and transfer your files easier.
Compression: While Tar collects files and directories, Gzip reduces the size of the tar file by compressing it. It will help you to save storage and transfer your data faster.
Quickly Learn To Extract Tar Gz Files in Linux Command Line
At this point, we assume that you have a tar.gz file and you want to extract it. Now you can follow the steps below to see how you can Extract Tar Gz Files in Linux Command Line.

Extracting a tar.gz File in Linux from CLI
Before begin toExtract Tar Gz Files in Linux Command Line, you must have the tar command line tool on your Linux OS. To install tar on Linux, you can use:
Debian / Ubuntu:
sudo apt install tar
RHEL / AlmaLinux / Fedora / Rocky Linux:
sudo dnf install tar -y
Next, you can use the following tar syntax to extract your tar.gz file:
tar -xvzf filename.tar.gz
Let’s see the meaning of the options in the above command:
- -x: Extract files from an archive.
- -z: Use gzip decompression.
- -v: Verbose mode (optional, for displaying progress).
- -f: Specify the archive file name.
This command will extract the file into your current directory. If you want to extract the file to another directory, you need to use the -C option:
tar -xvzf filename.tar.gz -C /path/to/directory
This will extract your file to your specified directory.
Conclusion
At this point, you have learned that tar.gz files are used in Linux for packaging software distributions, backups, and transferring or archiving large files and directories. If you have a tar.gz file, you can simply use the tar command with the required options to extract it.
Hope you enjoy using it. Also, you may like to read the following articles:
Transfer Files from the Linux Server to the Local Machine
Using Fasd in Linux for Quick Access to Files & Directories
Fix unknown filesystem type NTFS error in Linux
FAQs
What is a .tar.gz file?
A .tar.gz file is a compressed archive file created by first bundling multiple files into a single .tar archive and then compressing it using Gzip compression (.gz). This format is commonly used in Linux to distribute files and software.
What does each tar option mean for .tar.gz extraction?
As described in the above guide on Extract Tar Gz Files in Linux, Common options used with tar for .tar.gz files include:
-x: Extract.
-t: List the contents.
-z: Gzip decompression.
-f: Specify a filename.
-v: Verbose, which shows progress with each file extracted.