How do I make an archive of many files or a directory?

The Tape Archive program (tar) is used to create a single file from many files. Tar files are not smaller (compressed) than the original files, they are the union of all files archived. To compress tar files, use gzip or compress after creation.

Creating
Assume the current directory is called alpha and contains the files: abc; def; ghi; and jkl
To make a tar file of abc and def called mytar.tar you would type the following:

tar cvf mytar.tar abc def

To make a tar file of all the files in alpha, you could use:

tar cvf mytar.tar abc def ghi jkl

or

tar cvf mytar.tar *

or

cd ..;tar cvf mytar.tar alpha

The last example assumes you have permission to write in the parent directory of alpha.
To compress mytar.tar using gzip:

gzip mytar.tar

this will create mytar.tar.gz.

Extracting
Assume theirtar.tar file contains the files: abc; def; ghi; and jkl
To extract abc and def, you would type the following:

tar xvf theirtar.tar abc def

To extract all files you would type:

tar xvf theirtar.tar

If theirtar.tar arrived compressed as theirtar.tar.gz, you would first unzip it:

gunzip theirtar.tar.gz

.