CIS 4307: Using Tar Files

Tar makes it easier to handle multiple files by combining them into a single archive. With compression, the total file size can also be reduced.

Tar files are easiest to make when you have every file you want to be combined in a single directory. For your homework submissions, you should create directories for each homework. For instance, for the first homework I'd create a directory called lab1 and put all homework 1 files in that directory.

The syntax for running tar is:

tar -[options] [output file] [input files]

When I am finished with homework 1 and want to package it into a tar file, I'd go to the parent directory of the lab1 directory and type:

tar -z -cvf c43070100lab1.tar.gz lab1

Here, the options are 'z', which means compress using gzip, 'cv', which means create a new archive/show the files that are added, and finally there is a trailing 'f', which means the next argument is the target file for the create operation.

The output file is c43070100lab1.tar.gz. This is what you will submit on Blackboard.

Everything after the target file name are files that will be added to the archive. In this case, the directory lab1 will be added. By default, directories are added recursively meaning the contents of the directory are added to the archive.

Some other useful options that can replace 'c' is 't', which will show you the files in an archive, and 'x', which will extract the contents of the archive.