create and extract tar gz archives

Create and extract tar gz archives

One tool, that you need nearly every day on the linux command line ist the "tar" command. Even when i use it quite frequently, i forget the options that i need to create and extract a tar archive.

 

In this post i want to summarize how to create and extract an tar.gz archiv.

 

Create a tar.gz

A tar.gz archive can be build with the following command:

 

 

tar cfvz mein-archiv.tar.gz verzeichnis

During the creation the following options are used

  • c - create: This argument means, that we create the tar.gz archiv.
  • f - file: For the created archive we want to use a file
  • v - verbose: During the creation of the tar.gz we want to see the files that will be added to the archiv.
  • z - compress: We want to use gzip compression for the created archiv.

Extracting a tar.gz archive

To extract the tar.gz on a target system you can use the following command:

 

tar xvfz mein-archiv.tar.gz

For the extraction we have used the following options:


x - extract: We want to extract the tar.gz archiv
f - file: The input is a file
v - verbose: We want to see the extracted files of the tar.gz
z - compress: The input file is a gzip compressed archiv.

 

You can see a list of all available options for tar in the man pages.

 

 

man tar

Navigation