Simple tar commands

To archive files or directories you type something like:

    tar cf grepple.tar subdir1 subdir2

The c option is create a tar file, the f option is used to specify the name of the file that holds the archive. The other command line arguments are the files and directories you want to archive. All directories are recursively archived, i.e., all files and subdirectories will be archived. Sometimes you'll find it useful to archive all files in a directory, you might type:

    tar cf grepple.tar *

I usually use the v verbose option, and I type tar cvf ... so that the files being archived are printed. You can check to see what's in a tar file by replacing the c with a t (for title), thus tar tf grepple.tar will print all the files/directories that have been archived. To extract the files (untar them), you use x (for extract) in place of c.

It's often a good idea to tar an entire directory so that when it is untarred a single subdirectory will be created.

Thus if all your files are in a directory grepple, you could type

   tar cvf grepple.tar grepple

You can gzip (compress) files while they're tarred by using a z, i.e.,

   tar cvzf grepple.tgz grepple
One convention is that gzipped tar files have a .tgz suffix as shown above. These can be untarred without uncompressing by just replacing the c with an x.