This article is going to show you that How to Extract (Unzip) Tar Gz File in Linux operating system. If you want to learn that How to Extract (Unzip) Tar Gz File in Linux then this article is ideal for you.
In computing, A tar file is a software utility for collecting many files into one single file for easy storage, often called as a tarball, for backup purposes. Tar files are compressed after being created and it is save with .tar.gz file extension.
You can also used tar
command to extract(unzip) tar files, display a list of the files included in the archive, add files to an existing archived and many other operations.
How to Extract Tar Gz File in Linux
To extract a tar.gz file then use the --extract
(-x
) option by specify the archive file name after the f
option:
$ tar -xf archivename.tar.gz
When you run above command, it will automatically detect the given compress type and extract the archive file.
Use -v
option to display the names of the files which are being extracted on the terminal:
$ tar -xvf archivename.tar.gz
To extract the archive contents to another directory
In the Linux by default, tar
command will extract the archive file contents in the your current working directory . simply use the --directory
(-C
) option to extract archive file contents in a specific directory:
$ tar -xf archivename.tar.gz -C /home/studiesonline/files
When you run the above command, it will extract the archive file contents in the above give directory.
Extract only specific Files from a tar.gz archive
If you want to extract only some specific file(s) from a tar.gz archive file, then pass the space-separated list of file names which you want to be extract:
$ tar -xf archivename.tar.gz filename1 filename2
For extract only some specific directories from a tar.gz archive file, run the below command:
$ tar -xf archivename.tar.gz dirname1 dirname2
You can also extract some specific files from a tar.gz archive file using the --wildcards
option:
$ tar -xf archivename.tar.gz --wildcards '*.html'
The above command will extract all the files whose names end with .
html (HTML files).
Listing tar.gz file
Use the --list (-t)
option, to list the all content of a tar.gz
archive file:
tar -tf archivename.tar.gz
That’s all
If you find any error and issue in above steps , please use comment box below to report.
If our tutorials helped you, please consider buying us a coffee. We appreciate your support!
Thank you for your support.