Unzipping and extracting Tar.gz files is routine work for a system administrator or developer, so we’ve created a tutorial on extracting Tar.gz files easily using the command line.
What is a tar.gz File?
A tar.gz file combines TAR (Tape Archive) and GZ (Gzip) compression. Both technologies are free to use; they are used widely to get highly compressed and make single archives of multiple files. Learn – What are Tar and Gz? Difference between them.
Why Use tar.gz Files?
- Compression: Efficiently reduce the size of files for storing or transferring them.
- Archiving: Combines multiple files into a single archive.
- Cross-Platform: Supported on Linux, macOS, and Windows.
Extracting tar.gz Files on Linux
Most Linux systems come by default Tar tool to deal with the Archive files created using it.
- Open Command Terminal: Access the terminal to execute commands on your Linux distro. On Ubuntu, we can use a keyboard shortcut: Ctrl+Alt+T.
- Navigate to the Directory: Once you can access the Terminal, switch to the directory using the “cd” command, where the tar.gz file you want to extract is located.
cd /path/to/directory
- Extract the File: Use the given tar command syntax to extract the file.
tar -xzvf filename.tar.gz
- -x: Extract the files.
- -z: Uncompress the gzip file.
- -v: Verbose output.
- -f: Specify the filename.
Extracting tar.gz Files on macOS
Just like we have extracted the Tar file in Linux, the same command and steps can be followed for MacOS.
- Run MacOS terminal application.
- Navigate to the directory containing the tar.gz file.
cd /path/to/directory
- Use the tar command to extract the file.
tar -xzvf filename.tar.gz
Extracting tar.gz Files on Windows
Using 7-Zip GUI
- Download and install 7-Zip; if you don’t know how, here is the tutorial on 7-ZIp Windows installation.
- Locate the tar.gz File: Open File Explorer and navigate to the tar.gz file.
- Extract the File:
- Right-click the tar.gz file.
- Select “7-Zip” > “Extract Here” or “Extract to
filename
“.
Using the Command Line
On Windows 11, the Tar tool is available by default through the PowerShell or Command prompt.
- First, right-click the Windows Start button and select Terminal to open it.
- Using the “cd” command, first, navigate to the directory where the Tar.gz file is situated.
cd /path/to/directory
- Now, like Linux and MacOS, execute the given Tar command to extract the file
tar -xzvf filename.tar.gz
![Tar gz command in Windows 11](https://linux.how2shout.com/wp-content/uploads/2024/07/Tar-gz-command-in-Windows-11-1024x395.webp)
Conclusion
Unzipping and extracting tar.gz files is not difficult on any mainstream operating system, whether using Linux, Windows, or macOS. We have already discussed the syntax a user needs to follow; however, if you face any problems, let us know using the comment section. Last, don’t forget that Windows users can use Winrar or 7-Zip’s GUI to extract the Tart.gz files.
Other Articles: