The following command will create a gzipped (compressed) tar file (many files into one file) for a folder called “Downloads”. In other words all the files and folders in the “Downloads” folder are combined into a single file and compressed.
This is handy for creating backups of folders with a smaller size than the original.
Using tar
in addition to gzip
allows you to maintain directory hierarchies and permissions, which may be lost if using gzip
which only allows for compression of one file at a time.

# create a g-zipped archive of a folder and its contents
# -c create a new archive
# -z archive is compressed with g-zip
# -f file archive name (argument following)
# -v verbose. list files processed
tar -czvf documents.tar.gz Documents
# creates a file called documents.tar.gz
The output of this process documents.tar.gz
can then be copied to another machine or hard drive.