tar is a program which can be used to package and unpackage files using the .tar format.

What About .tar.gz Files?

.tar.gz files are files which have been packaged by tar, and then compressed with gzip. Fortunately, tar can both uncompress and unpackage in one step. Usually you would want to use the following command:

The above options are:

Argument Description
x  Instructs tar to decompress the archive.
v  Verbose output.
z  Tells tar to decompress the archive using gzip.
f  The file to decompress and unpackage. This must be the last argument in the group, and the file name must follow directly after.

Uncompress To Specific Folder

By default, tar will uncompress the files into the current working directory. Sometimes you will want to specify the folder manually. To do this with the GNU version for tar, you can use the -C option.

Note that destination_folder has to already exist, tar will not create it for you.

--directory is the long name for -C.

What About .tar.xz Files?

tar can also decompress and extract .tar.xz files. The -J flag can be used to specifically deal with .xz files:

Also note that more recent versions of tar can automatically workout the compression format for you! Just use:


Posted: April 9th, 2017 at 12:25 pm
Last Updated on: June 20th, 2017 at 5:18 am