tar file compression and decompression




Tar file compression and decompression


Purpose:



It is the GNU version of the tar archiving utility

Usage:






Main Operations are:




Description




Creating an uncompressed tar archive using option cvf



This is the basic command to create a tar archive.

$ tar cvf archive_name.tar dirname/


In the above command:


  • c – create a new archive


  • v – verbosely list files which are processed.

  • f – following is the archive file name


The above tar cvf option, does not provide any compression.

  1. tar using gzip


To use a gzip compression on the tar archive, use the z option as shown below.
tar cvzf compressed.tar.gz screenshot





It will create a compressed file called compressed.tar.gz of directory screenshot. To later decompress the file and expand the archive, you can use the -x flag:



 

 This will recreate the directory structure in the current directory.






2. tar using bzip2


To use archiving with bzip2, you can replace the -z flag, which is gzip-specific, with the -j flag.


 It will create a compressed file called compressed.tar.bz2 of director scrennshot.



To later decompress the file and expand the archive, you can use the -x flag:


 


 This will recreate the directory structure in the current directory.





 



These follow the exact same format using the -J flag.


 


It will create a compressed file called compressed.tar.xz of directory scrennshot.



 
To later decompress the file and expand the archive, you can use the -x flag:


 

  This will recreate the directory structure in the current directory.





Comments