Colorado State University

How To Tar Your Files



What is Tar?

Tar (Tape archive) is a UNIX utility program to read or write multiple files from/to a single file. Originally, this was used to move a whole directory of files to/from a magnetic tape. Now it is a common storage method for bundling and transporting sets of files.

The format of a tar file can usually be read by many different types of systems. In addition, single files can be extracted from a tar file or can be appended to an existing tar file.


How to Tar Your Files

tar instructions:

  1. Put all the files you want to put together into some directory; there should be nothing else in this directory. Often, it is a directory you create just for this purpose.

  2. To tar the files: Suppose you have placed the files to be submitted into a directory named Homework3 for the following example. From the parent directory, enter the following command:

          tar -cf ILoveHomework.tar Homework3

    Comments:

    • The c tells tar to create a new tar file
    • The f tells tar to name it ILoveHomework.tar
    • You have to supply the .tar extension in the command.

    This command creates a new file in the parent directory named ILoveHomework.tar (of course, you may call it anything you wish). When this file is untarred, the Homework3 directory and its contents are automatically recreated.

    Once you have created the tar file above, it contains the all files within a single file.