Compress a file with tar

Last time we spoke about unzipping an archive/compressed with tar. This time we’re going to show you how to compress a file with tar. Tar as you know it is most commonly used for unzipping compressed files and unzipping archived files. Both archived files and compressed files contain multiple files combined into one. This makes it easier for sending files or storing them. The major difference is that a compressed files are generally smaller. (Hence the name) Archived files remain the same size, but become one file until extracted.

Here is the run down. Tar is used with the options c & f which mean, to create a new archive and f specifies that it is a file. When creating an archive with tar, you must select a directory you plan to archive. Once you have either made or selected a directory you may begin.


# tar -cf {file.tar} {file} {file} {file}


As you can see in the photo, we first created several files. Then created a directory that we’re going to archive. Next we began archiving, which we added specific files to be archived.  Once the process was completed, the original files were still there, but there was a new archive file where which contains everything.

Here is the kicker, you can added more files to an already archived/compressed file with tar. Check out the syntax below.

# tar -cf {file.tar} {file}

Its that easy. You specify the archived/compressed file and  then tell it what file is being added to it. (See Below)

For more information you can see the man page or type in “tar –help”


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s