How To Open a Tar.gz File In Linux / Unix

In Linux or Unix, you can extract the contents of a .tar.gz file using the tar command. Here’s how:

  1. Navigate to the directory where the .tar.gz file is located using the cd command.
  2. Use the following command to extract the contents of the .tar.gz file:
    tar -xzvf file.tar.gz

    Replace file.tar.gz with the actual name of the .tar.gz file you want to extract.

  3. The -x option tells tar to extract the contents of the archive. The -z option tells tar to decompress the archive, which was compressed using gzip. The -v option enables verbose output, which means tar will display the names of the files it’s extracting. The -f option specifies the file name of the archive.
  4. After the extraction is complete, the contents of the .tar.gz file will be in a new directory with the same name as the archive, minus the .tar.gz extension.
  5. You can now access the contents of the .tar.gz file in the new directory.

Leave a Comment