How to Extract tar.gz / tar.bz2 / tar.xz Files on Linux

How to Extract tar.gz / tar.bz2 / tar.xz Files on Linux including Ubuntu, Debian, RHEL, CentOS, Arch Linux, Linux Mint, etc. The TAR command is create in Linux for archiving backup data to a Tape drive. The tar commands has large amount of advantage so that is used by most of the Linux system admins for Backup and restoring purposes. The tar balls are most popular method to archiving data into tar files including various extensions like tar.gz / tar.xz / tar.bz2 etc. The tar command is developed to achieve data with robust tar ball files. This is most widely used Linux commands for most probably used for the backup. When any backup is archiving with this method then question arises here how to exact the tar balls. This tutorial show how extract those tar ball files.

How to Extract tar.gz / tar.bz2 / tar.xz Files on Linux ?

Syntax of command
For tar.gz file
$ tar -recommended-options filename.tar.gz -optional-options
For tar.bz2 file
$ tar -recommended-options filename.tar.bz2 -optional-options
For tar.xz file
$ tar -recommended-options filename.tar.xz -optional-options
Options
Recommended Options
  • x : Extract
  • v : Verbose Mode
  • f : File Name
  • z : Decompress for tar.gz file only
  • j : Decompress for tar.bz2 file only
  • J : Decompress for tar.xz file only
Optional Options
  • C : Followed by the Path of Destination Directory
Extract Files in Same Current Directory
For tar.gz file
$ tar -xzvf techbrown.tar.gz
For tar.bz2 file
$ tar -xjvf techbrown.tar.bz2
For tar.xz file
$ tar -xJvf techbrown.tar.xz
Extract Files in Particular Destination Directory
For tar.gz file
$ tar -xzvf techbrown.tar.gz -C /home/techbrown/
For tar.bz2 file
$ tar -xjvf techbrown.tar.bz2 -C /home/techbrown/
For tar.xz file
$ tar -xJvf techbrown.tar.xz -C /home/techbrown/
Tar Command More Options or Help Manual
$ man tar

Conclusion

Finally you have extracted the tar ball using above commands where you have lean about how to extract those files using various tar files with ease using your favorite Linux terminal. If you have any issues and comments please use the comment section below for more info.

Related Post

Develop New SysAdmin Skills with E-books (FREE Download)

COMMENTS