some common tar flags:
$ tar --help | egrep " -c, | -u, | -v, | -z, | -Z, | -j, | -p, | -f, | -x," -c, --create create a new archive -u, --update only append files newer than copy in archive -x, --extract, --get extract files from an archive -p, --preserve-permissions, --same-permissions -f, --file=ARCHIVE use archive file or device ARCHIVE -j, --bzip2 filter the archive through bzip2 -z, --gzip, --gunzip, --ungzip filter the archive through gzip -Z, --compress, --uncompress filter the archive through compress -v, --verbose verbosely list files processed $
To archive and compress with gzip a directory
$ tar -cvpzf ipduh.com.tar.gz ipduh.com
The ipduh.com directory is approximately 90% ASCII and 10% binary files.
Let 's compare the directory and the compressed archive sizes.
$ du -h --max-depth=0 ipduh.com 8.5G ipduh.com $ du -h ipduh.com.tar.gz 774M ipduh.com.tar.gz $This is a good compression rate.
Let' s archive and compress the same directory with bzip2
$ tar -cvpjf ipduh.com.tar.bz2 ipduh.com
And what is the size of the compressed archive?
$ du -h ipduh.com.tar.bz2 545M ipduh.com.tar.bz2That's a better compression rate, but it takes more time.
notes on archiving and compression --that GNU howto
archive and compress a directory linux