Knowledgebase


Portal Home > Knowledgebase > Hosting FAQ's > How to use tar command on linux server?

How to use tar command on linux server?

“Untar” a file
If you are working with example.tar  file, you can extract the files from it using:

 

tar xvf example.tar

 

If you are working with  gzipped(example.tar.gz), you can extract the files from it using:

 

tar xvfz example.tar.gz

 

If  you have example.tgz, you can extract the files from it using:

 

tar xzvf example.tgz

If the tarball has been compressed with bzip2(example.tar.bz2), then you will need to

have bzip2 installed. (If all is well and bzip2 is installed, you can extract the files from it

using:
tar yxf example.tar.bz2

Sometimes you only want to extract certain directories from the tarball.

An example of doing so would be:

tar xvzf example.tar.gz */DIRECTORY_YOU_WANT_REPLACES_THIS_TEXT/*

 

If you would like to see what is inside a tarball, you can use the command:

tar tvf example.tar

 

If you would like to see what is inside a gzip’d tarball, you can use the command:

tar tzf example.tar.gz


Also Read