Linux Archive and Compression

Compressing and extracting files

tar Archive

tar -cvf archive.tar files # create tar archive
tar -xvf archive.tar # extract tar archive
tar -tvf archive.tar # list contents

tar with gzip

tar -czvf archive.tar.gz files # create compressed archive
tar -xzvf archive.tar.gz # extract compressed archive

tar with bzip2

tar -cjvf archive.tar.bz2 files # create bzip2 archive
tar -xjvf archive.tar.bz2 # extract bzip2 archive

gzip

gzip file # compress file (creates file.gz)
gzip -d file.gz # decompress
gunzip file.gz # decompress (alternative)

zip/unzip

zip archive.zip files # create zip archive
zip -r archive.zip directory # zip directory recursively
unzip archive.zip # extract zip
unzip -l archive.zip # list contents