User Tools

Site Tools


linux:sysadmin:compression_and_archives

Archives and file compression

Comparison between compression algorithms

Algorithm Comments
gzip + fast compression
- medium compression rate
bzip2 + slow compression
- high compression rate

Equivalent File Suffixes

Short Long
.tgz .tar.gz
.tbz, .tbz2 & .tb2 .tar.bz2
.taz .tar.Z
.tlz .tar.lz
.txz .tar.xz

tar archiving utility

Create a archive of a directory

using tar (no compression)

tar -cvf www.example.com.tar /home/www/www.example.com/

using gzip compression

tar -czvf alldocs.tgz *.doc

using bzip2 compression

tar -cvjf www.example.com.tbz /home/www/www.example.com/

Extract the contents of a archive with tar

Extract a tar archiv

tar -xvf foo.tar

Extract a gzip archiv

tar -xvzf foo.gz

Extract a bz2 archive

tar -xjvf file.tar.bz2

Show a tar file's table of contents

tar -tzf foo.gz

bzip2

Files compressed with bzip2 usually have the .bz2 extension. Note that bzip2 also will change file names after decompression:

archive name file name after decompression with bzip2
filename.bz2 filename
filename.bz filename
filename.tbz2 filename.tar
filename.tbz filename.tar
anyothername anyothername.out

Create a bzip2 archive from a file

bzip2 -f filename

Decropress a bzip2 archive

bunzip2 filename
/srv/wiki.niwos.com/data/pages/linux/sysadmin/compression_and_archives.txt · Last modified: 2013/02/07 09:31 by niwo