In Linux or Unix, you can extract the contents of a .tar.gz file using the tar command. Here’s how:
- Navigate to the directory where the
.tar.gzfile is located using thecdcommand. - Use the following command to extract the contents of the
.tar.gzfile:tar -xzvf file.tar.gz
Replace
file.tar.gzwith the actual name of the.tar.gzfile you want to extract. - The
-xoption tellstarto extract the contents of the archive. The-zoption tellstarto decompress the archive, which was compressed using gzip. The-voption enables verbose output, which meanstarwill display the names of the files it’s extracting. The-foption specifies the file name of the archive. - After the extraction is complete, the contents of the
.tar.gzfile will be in a new directory with the same name as the archive, minus the.tar.gzextension. - You can now access the contents of the
.tar.gzfile in the new directory.