Linux tar gz, bz2, xz comparison

In the UNIX/Linux community, traditionally, if you want to compress files, you usually use tar plus gzip compression. Later, gzip is gradually replaced by bzip2, and now more and more people are using LZMA2. Xz to compress the tar file, even kernel.org also started from the end of 2013, while using the tar.gz and tar.xz compression format to release the Linux kernel source code, while the hyperlink on the home page is directly using tar. Xz This format, the previous tar.bz2 is directly discarded.

tar.gz or tgz

// Compress 
tar zcvf file_name.tar.gz dir_name
// Decompress
tar zxvf file_name.tar.gz

tar.bz2

// Compress
tar jcvf file_name.tar.bz2 dir_name
// Decompress
tar jxvf file_name.tar.bz2

tar.xz

// Compress
tar Jcvf file_name.tar.xz dir_name
// Decompress
tar Jxvf file_name.tar.xz

tar archive

// Tar archive without compress
tar -cvf /home/www/images.tar /home/www/images
// untar
tar -xvf images.tar /

Photo by Joshua Newton on Unsplash