Linux TAR Command

Quick Start: Here we’l present quick start examples explained.

Create linux tar gz (Gzip) archive

tar -czvf myarchive.tgz mydirectory/

We use the -t option to create an linux tar archive
-c, –create                      create a new archive

Note that .tgz is the same thing as .tar.gz

Create linux simple tar archive (withouth compresion)

tar -cvf myarchive.tar mydirectory/

Extracting linux tar archive:

Extract linux tar gz (Gzip) archive
tar -xzvf mystuff.tgz

Extract linux simple tar archive
tar -xvf mystuff.tar

We use -x to extract the files form the tar archive
-x, –extract, –get    extract files from an archive

And now let us shortly explain this command

Usage: tar [OPTION]… [FILE]…

Let us check the option used in this example

-c, –create                      create a new archive
-z, –gzip, –ungzip        filter the archive through gzip
-v, –verbose                   verbosely list files processed
-f, –file=ARCHIVE          use archive file or device ARCHIVE

Testing / viewing your archive

tar -tvf myarchive.tar
tar -tzvf myarchive.tgz

Here we used the - t opton
-t, –list                           list the contents of an archive

————————————————-

Go ahead, try out these commands and stay tuned; we will come up with more doccumentation on linux tar command

Tags: , , ,

3 Responses to “Linux TAR Command”

  1. Matt Says:

    Thanks for the great help keep the good work

  2. Webdevelopment Says:

    Thanks, as newbe it surprises me that you cant extract to a defined location.
    Copy the tarball to the root of the location first.

  3. Matt Says Says:

    Thanks for the great help keep the good work

Leave a Reply