How to Extract or Unzip .tar.gz Files in Linux

August 30, 2024 / General Discussion

This guide explains how to extract or unzip ‘.tar.gz’ files using Linux command-line tools.
A ‘.tar.gz’ file is a mixture of two formats: .tar (Tape Archive) and .gz (Gzip compression). These files are common in Linux environments for compressing and archiving multiple files and directories.

Follow the steps:

1. Open Terminal:

To extract a ‘.tar.gz’ file, first, open the Terminal on your Linux system. You can usually do this by searching for “Terminal” in your applications menu or using a keyboard shortcut (Ctrl + Alt + T).

2. Navigate to the directory:

Use the cd command to navigate to the directory where the ‘.tar.gz’ file is located. For example:

cd /path/to/your/file

3. Extract the ‘.tar.gz’ file:

To extract the contents of a ‘.tar.gz’ file, use the subsequent command:

tar -xvzf filename.tar.gz

‘-x’: Extract the files.
‘-v’: Verbose mode (shows the extraction process).
‘-z’: Use gzip to decompress.
‘-f’: Specifies the file name.

For example:

tar -xvzf archive.tar.gz

4. Verify Extraction:

Once the extraction is complete, you can list the files using the ls command to verify the contents:

ls

5. Optional: Extract to a Specific Directory

If you want to extract the contents to a specific directory, use the -C option with the tar command:

tar -xvzf filename.tar.gz -C /path/to/directory

This way, you can easily extract or unzip .tar.gz files in Linux. If you run into any issues during the process, do not hesitate to reach out to our support team for assistance.

Learn more about How to Unzip Files via Command Prompt: Master the steps to quickly extract compressed files using simple commands.

Leave a Reply

Your email address will not be published. Required fields are marked *