FileCompression

Compressing or Decompressing files from the unix command line is quite simple. There are a couple of common compression methods:

GZIP (file.txt.gz)

Compress file (ie. produce a .gz compressed file)

file.txt

gzip file.txt

Decompress file

file.txt.gz

gunzip file.txt.gz

BZIP2 (file.txt.bz2)

Compress file (ie. produce a .bz2 compressed file)

file.txt

bzip2 file.txt

Decompress file

file.txt.bz2

bunzip2 file.txt.bz2

TAR (file.tar) - Tape ARchive - Generally used to gather a folder the files and sub-folders contained within into a single file

Archive folder with tar alone

MyData/

tar cvf MyData.tar MyData/

Archive with tar and Compress with gzip or bzip2

MyData/

tar cvzf MyData.tar.gz MyData/
OR
tar cvjf MyData.tar.bz2 MyData/

Unarchive Standard or Compressed Tar Files

file.tar

tar xvf file.tar

file.tar.gz

tar xvzf file.tar.gz

file.tar.bz2

tar xvjf file.tar.bz2

Notes:

c = Create

x = eXtract

v = File to manipulate

z = File to manipulate is gzip-compressed

j = File to manipulate is bzip2-compressed