tar (tape archive) command is a utility that I use quite frequently.
tar takes a file or group of files and combines them into one file which can then be later extracted.
This is useful when moving or copying many files from one location to another is unwieldy.
Just tar them up into a tarball and copy or move the single file. The
tar command creates files that end in the .tar extension.
The most basic
tar command is like this:
# tar -cf archive.tar one two
The above takes file one and file two and puts them into one single file named archive.tar which can be on a separate device or then be copied or moved to different location.
gzip (GNU zip) is a compression utility designed to be a replacement for compress.
Its main advantages over compress are much better compression and freedom from patented algorithms.
Command is very simple:
# gzip one
which ends up giving you a compressed file called one.gz.
To get uncompressed file back, just type:
# gzip -d one.gz
The other way of unzipping gzipped files that is with gunzip. Its the same as using the -d flag and works like this:
# gunzip one.gz
tar + gzip
tar command is typically used with some form of compression. One of the main purposes of
tar is to take a bunch of files
and compress them down into one smaller file. One of the most commonly used compression methods in conjunction with
By adding the z flag as an option the files that are added to the
tar are compressed using the
gzip compression utility.
That command would look something like this:
# tar -cfz archive.tgz one two
The tgz extension is equivalent to .tar.gz.
To un-tar a tarball the x (extract) flag is used instead of the c (create) flag:
# tar -xfz archive.tgz one two
There are different compression methods that work in conjunction with
tar but very often the
gzip method is used.
bzip2 program is just another zipping tool. You use bzip2 the same way you use the other zipping tools:
# bzip2 one
As result you recive a file called one.bz2.
To unzip it you would simply use the -d flag or similar to above:
# bunzip2 one.bz2
Speaking of zipping, If you want to zip up files in a format that is Windows zip compatible then you can use the
Lets say you want to zip up your entire home directory into a zip file:
# zip -r archive.zip ~/*
The -r tells zip to compress the directory recursively.
Now you need to unzip the files now that they are all zipped up:
# unzip archive.zip