Usage
tar
is a classic UNIX ulitily to make archives out of directories and files.
unlike most other archive formats, tape generally does not compress on it's own,
but rather thru other programs such as gzip
, bzip2
, compress
or xz
.
Creating archives
To make an archive out of /bin
directory:
$ tar cf bin.tar /bin
c
means to create an archivef
is used to specify an tar file
You may also add v
argument to
print every file and directory that is being added to archive or extracted.
Creating compressed archives
You may compress the archives you make with tar on the fly, for example to compress with gzip(1):
$ tar czf bin.tgz /bin
Here we used .tgz
extenstion instead of .tar
since we are using a gzipped (gz
) tar file. another common extentision for gzipped tar files is .tar.gz
, but tgz
is prefered for compatablity with older systems and partitions.
Extracting
To extract an archive:
$ tar xf bin.tar
If it's compressed with gzip(1):
$ tar xzf bin.tgz