If you are wondering in Linux how to unzip tar.gz file then this tutorial is made for you. This tutorial explains how to compress and decompress tar.gz files on Linux using the tar command. You can choose between using the GUI or the terminal with the possibility to choose between different compression software (gzip, bzip2 or xz) according to your needs.
To unzip tar.gz files on Linux into the current directory, enter the following command in the Terminal : tar -xvf archive.tar.gz
How Archives and compression work on linux
On Linux, the tar command is used to create archives in .tar format.
By default, an archive is not compressed. It will be necessary to use a compression software (gzip, bzip2 or xz) to compress the archive, which will result in an archive in .tar.gz, .tar.bz2 or .tar.xz format.
The tar command – natively included in all Linux distributions handles compression. It allows to create a .tar archive, then to compress it with a compression software such as gzip, using a single command.
How To Unzip tar.gz File Using The Terminal on Linux
To unzip tar.gz files on Linux we use the tar command that is able to extract (decompress) an archive.
To unzip tar.gz files on Linux into the current directory, enter the following command in the Terminal :
tar -xvf archive.tar.gz
This is actually the same command used to create an archive, except that we use the -x option (instead of -c for creating an archive) which tells tar to unzip an archive.
How To Unzip a tar.gz File to a Specific Directory
To unzip the contents of the tar.gz archive to a specific directory, you will need to add the -C option. For example, to extract the files of the archive.tar.gz file into the /techlou directory, enter the following command :
tar -xvf archive.tar.gz -C / techlou
The tar command will automatically detect the compression algorithm used on your archive to unzip its content.
The -v parameter tells the tar command to be more “visible” by listing the files being uncompressed.
How To Unzip Specific Files from a tar.gz File
The tar command allows you to extract specific file(s) from a tar.gz archive on Linux. Just type this command to extract specific files from your tar.gz file:
tar -xf techlou.tar.gz file1 file2
You can unzip directories from your archive using this command:
tar -xf techlou.tar.gz dir1 dir2
How To Unzip Files With a Specific Extension from a tar.gz File
Use the command below to extract files having a specific extension from a tar.gz.
For example to unzip *.jpeg files from a tar.gz, use this command:
tar -xf techlou.tar.gz --wildcards '*.jpeg'
This command using the “*.jpeg” wildcard will extract all files having the .jpeg extension. Pretty handy command when you have a huge archive and you want to extract only some specific files having the same extension.
How To Unzip tar.gz File Using The Desktop GUI on Linux
Desktop environments such as GNOME and KDE Plasma provide the capability to compress and decompress tar.gz files through their file managers.
You can unzip tar.gz files by simply right-clicking on the archive file and click on “Extract“. This works on any desktop environment such Gnome, KDE or Xfce.
Conclusion
In this article we saw how the simple tar command allow you to unzip almost any archive on Linux using the Terminal. If you still have a hard time remembering this command, you can stick to the standard Windows-like method using the right click of your mouse to extract tar.gz files.
See also: WindowsFX 10, The Linux That Looks 100% Like Windows
Contrary to many views, better researched articles still fetch in reviewers like me. You demonstrated clear understanding of the subject matter and my sentiments are now complete after reading your post. Please hold up the solid work and i will subscribe to your rss feed to be advised of any future postings.