What Are Linux Tarballs And How Can You Use Them

Stick your data into tarballs for convenient archiving

Tape Archives (TAR)
Tape Archives (TAR).

A tarball file combines several files into a single—usually compressed—file.

In the past tar files were created for storing data to tapes and the term tar stands for tape archive. Although it can still be used for this purpose, a tar file nowadays is simply a way to group lots of files together in one archive.

How to Create a Tar File

To create a tar file, use the following syntax:

tar -cf tarfiletocreate listoffiles

For example:

tar -cf garybackup ./Music/* ./Pictures/* ./Videos/*

This command creates a tar file called garybackup with all the files in the music, pictures and videos folders. The resulting file is completely uncompressed and takes up the same size as the original folders.

This isn't great in terms of copying over a network or writing to DVDs because it will take up more bandwidth, more disks and will be slower to copy.

Use the gzip command in conjunction with the tar command to create a compressed tar file. In essence, a zipped tar file is a tarball.

How to List the Files in a Tar File

To get a list of the contents of a tar file uses the following syntax:

tar -tvf tarfilename

For example:

tar -tvf garybackup

How to Extract a Tar File

To extract all the files from a tar file using the following syntax:

tar -xf tarfilename