Published on

Unix Utility Commands for Archiving

Authors

Compress a folder to .tar

tar -xvf file.tar folder/

Decompress to .tar

tar -xvf file.tar

Compress to .Z

compress file

Compress to .gz

gzip file or tar -zxvf file.tar folder/

Unzip file.gz

gzip -d file.gz or tar -zxvf file.tar or gunzip file.gz

Display the archive contents without extracting it

tar -tf file.tar

Add a file

tar -rvf file.tar file_to_add

Create a gzip archive

tar zcvf your_archive.tar.gz your_folder/

Extract a gzip archive

tar zxvf your_archive.tar.gz

Create a Bzip2 archive. Bzip2 creates much smaller files than Gzip, but uses more CPU resources, especially for compression.

tar jcvf your_archive.tar.bz2 your_folder/

Extracting a Bzip2 archive

tar jxvf your_archive.tar.bz2

Creating an archive, archiving multiple files

tar cvf archive.tar archivefile1 archivefile2...

Creating an archive of a folder

tar cvf archivefolder.tar folder/