How to Unzip .tgz File Using the Linux Terminal?
Last Updated :
18 Sep, 2024
If you’ve come across a .tgz file and are unsure how to access its contents, you’re not alone. Knowing how to extract or unzip a .tgz file in a Linux environment can be highly useful, especially when handling compressed files for software installations, backups, or data transfers. Here, we will walk you through the steps to easily unzip .tgz files using the Linux terminal, ensuring you can access the contents quickly and efficiently.
What is a '.tgz' or '.tar.gz' File?
A `.tgz`
file is essentially a tar archive that has been compressed using gzip compression. It combines two formats:
- TAR (Tape Archive): This format bundles multiple files together into one archive. Think of it as a way to package files.
- GZIP: This is a compression algorithm applied to reduce the size of the '.tar' file.
The '.tgz' or '.tar.gz' extension denotes that the file is a TAR archive that has been compressed using GZIP. This combination helps in reducing the overall file size, making it easier to store or transfer.
- TGZ File is the extensive version of the TAR File Format.
- TGZ File Format comes from the expression tar.gz
- The TGZ Files are created first by converting them to TAR files and then compressed to ZIP.
- TGZ Files are also known as the Tarballs.
- Linux can read specific commands in TGZ Files.
How to Unzip .tgz File Using Linux Terminal?
Extracting .tgz files in Linux is easy once you know the right commands. The most common method involves using the tar command, but you can also use gunzip if needed. Here’s a step-by-step guide for both methods:
Method 1: Unzip .tgz File Using the tar Command
The tar
command is a versatile utility that is used to manipulate archives. To unzip .tar.gz
file using `tar`
command. You can extract .tgz file in following ways.
1. How to Navigate to the Directory Containing the .tgz File?
Use the cd
command to navigate to the directory where your .tgz
file is located. For example, if your file is in the Downloads folder, you would use:
cd Downloads
2. How to View the Contents of the .tgz File?
Before extracting the contents of the `.tgz`
file, you can view its contents using the following command:
tar -ztvf yourfile.tgz
Replace `yourfile.tgz`
with the name of your `.tgz`
file. This command will list the contents of the archive without extracting them
To extract the content of .tar.gz
file, use the following command:
tar -xvzf <tgz file name>
Replace `tgz file name` with the name of your `.tgz`
file. This command will extract the contents of the archive into the current directory.

You have successfully Extracted TGZ Files on the Linux Terminal with the best Unzipping TAR Command.
If you want to extract the contents of .tar.gz
file into a specific directory, you can use the `-C`
option followed by the path to the directory. For example, to extract .tgz file into a directory named `myfolder`
in your current directory, you would use:
tar -xzvf yourfile.tgz -C myfolder
Also Check: How to Compress and Extract Files Using the tar Command on Linux?
Method 2: Unzip .tgz File Using the gunzip
Command
The `gunzip
`
command is used to decompress files that have been compressed using the gzip utility. Here's how you can use it to unzip .tar.gz
file.
1. How to Navigate to the Directory Containing the .tgz File?
Use the cd
command to navigate to the directory where your .tgz
file is located. For example, if your file is in the Downloads folder, you would use:
cd Downloads
2. How to Unzip the .tgz File Using gzip Command?
To unzip the `.tgz`
file, use the following command:
gzip -d <tgz file name>

Replace `tgz file name` with the name of your `.tgz`
file. This command will decompress the `.tgz`
file and remove the original `.tgz`
file.
Once the `.tgz`
file is decompressed, you will have a `.tar`
file. You can extract the contents of .tar.gz
archive file using the tar
command:
tar -xvf yourfile.tar
Replace `yourfile.tar`
with the name of your `.tar`
file. This command will extract the contents of .tgz
archive into the current directory.
So, these are the direct commands that can Decompress TGZ File Format on the Terminal. You can use any of the commands to Unzip TGZ File on Linux Terminal. Just put the entire TGZ File Format Name along with the TGZ File Extension to get your job done. Otherwise, it can cause issues with the Open Linux TGZ File on Terminal.
Conclusion
Unzipping a .tgz file on Linux is a straightforward process once you know the right commands. By following the above mentioned steps, you can quickly and efficiently extract .tgz files using the Linux terminal, saving time and avoiding potential errors. Whether you're handling backups, software packages, or any other type of compressed file, mastering this skill will make your Linux experience much smoother.
Also Read
Similar Reads
How to unzip a file using PHP ? To unzip a file with PHP, we can use the ZipArchive class. ZipArchive is a simple utility class for zipping and unzipping files. We don't require any extra additional plugins for working with zip files. ZipArchive class provides us a facility to create a zip file or to extract the existing zip file.
2 min read
How to Download File on Linux Terminal Downloading file on Linux is a basic operation, and the right command-line tool makes a huge impact in terms of speed, efficacy, and customization. While the graphical interface for simple downloads, CLI-based programs like wget, curl, axel, and aria2 come with features of parallel downloading, auth
7 min read
How to open ISO files on Ubuntu Linux ISO files are disc image archives commonly used to distribute software and operating systems. There are two main ways to access the contents of an ISO file on Ubuntu Linux: using the graphical user interface (GUI) or the command line. What is an ISO File?An ISO file or an ISO image is a single data
5 min read
How to uncompress a ".tar.gz" file using Python ? .tar.gz files are made by the combination of TAR packaging followed by a GNU zip (gzip) compression. These files are commonly used in Unix/Linux based system as packages or installers. In order to read or extract these files, we have to first decompress these files and after that expand them with th
2 min read
How to Install Zip and Unzip in Linux? Zip is a command-line compression utility for files and directories. File and folder compression allows for quicker and more reliable file and folder transfer, storage, and email. Unzip, on the other hand, is a program that allows you to decompress files and directories. zip is used to compress the
2 min read
How to Unzip Files on Windows and Mac? The useful data from a particular file, several files, or a specific folder is compressed using ZIP files and stored in a single, smaller storage unit as per requirement. Data compression speeds up data interchange via email and text messaging while also improving the performance of local and cloud-
5 min read
How to Compress and Extract Files Using the tar Command on Linux Tar archives are special files that bundle multiple files and directories into a single file, making it easier to store, share, and manage. While tar archives themselves are not compressed, they can be combined with various compression utilities to reduce their size. The tar command is highly versat
3 min read
How to Use Gzip and Keep Original File in Linux? Gzip is a pretty powerful command-line tool that comes pre-installed with most Linux operating systems. Users often use it to compress files, thereby turning them into much smaller file sizes. Gzip, by default, overwrites the original file with a compressed copy of it having the .gz extension name.
3 min read
Unzipping files in Python In this article we will see how to unzip the files in python we can achieve this functionality by using zipfile module in Python. What is a zip file ZIP file is a file format that is used for compressing multiple files together into a single file. It is used in an archive file format that supports l
3 min read
How to Run a File in Linux The command line is one of the most powerful tools in Linux. It allows you to execute commands, manage files, and automate tasks all from a single terminal window. One common task you'll often need to do is run a file, whether itâs a script, a compiled program, or even a text file. In this article,
6 min read