Archive for February, 2011

compress & decompress files under Linux

February 24th, 2011

.zip

compress:

zip -r xxx.zip dir

decompress:

unzip xxx.zip

.rar

compress:

rar a xxx.rar dir

decompress:

unrar e xxx.rar

.bz2

compress:

bzip2 file

decompress:

bunzip2 xxx.bz2 (NOTE: use the switch -k to keep the .bz2 file)

.gz

compress:

gzip file (NOTE: -r, --recursive   operate recursively on directories)

decompress:

gunzip xxx.gz

tar.bz2

compress:

tar -cjf xxx.tar.bz2 dir

decompress:

tar -jxvf xxx.tar.bz2

tar.gz

compress:

tar -czf xxx.tar.gz dir

decompress:

tar -zxvf xxx.tar.gz