Tar and Untar files in Linux

.tar files are similiar to .zip files, but they can be simple collections of files, or they can be compressed using gzip or bzip.  Tar files also known as tarballs can be used for transfering files, or just archiving and backup purposes.  Below we run through how to create and unpack each set of file types.

Creating the tar:

tar -c <target name> <folders or files to be tared separated by a space>

example:

tar -c tarball.tar myfolder

Untar a file:

tar -xvf <filename>

example:

tar -xvf mytarfile.tar

 

Compress your files with GZIP:

tar -czvf <target file> <folders or files to be tared separated by a space>

example:

tar -czvf mytarfile.tar.gz myfolder

Untar a tar.gz file:

tar -xzvf <filename>

example:

tar -xzvf mytar.tar.gz

 

Compress your files with BZIP:

tar -cjvf <target file> <folders or files to be tared separated by a space>

example:

tar -cjvf mytarfile.tar.bz2 myfolder

Untar a tar.bz2 file:

tar -xjvf <filename>

example:

tar -xjvf mytar.tar.bz2

Category: 
Share: 

GuardianMS
Guarding your IT Experience!

Comments

great resource here

Add new comment