Compress Entire Directory to tar archive

Jul 2017

tar files are compressed files that contain all files and folders from a given location. The advantage to using .tar files, other than the obvious (potential) space saving is that you can include all file/folder permissions in the .tar file that would potentially be lost if you were doing a straight copy.

.tar Syntax

The basic syntax for tar is quite simple, here is an example:

tar -switches xxx.tar.gz ABC

There are many switches available for .tar, but the main ones we will be using are:

p == preserve permissions
c == create archive
v == verbose (print names while making tar)
z == gzip
f == tar file name