What are tar files? How to create a tar archieve ?

Share on :

Tar

Tar is used to create the archive of any folder or partition, so that huge data under various directories & files can be stored as single file. Tar is generally used to store the data on tape drives in production environment.

Creating a tar file : -


[email protected] # tar   -cvf   etc.tar   /etc


[email protected] # ls

[email protected] #  etc.tar

-c is used to create tar, -v is verbose and -f is file name. Here we are creating tar of /etc directory with name etc.tar

[email protected] # tar    -tvf   etc.tar

View data under any tar file

[email protected] # du   -sh   etc.tar

This command will show the size

[email protected] # tar   -xvf   etc.tar

Extracting etc.tar, you need to change your pwd(present working directory), where u want to extract the tar


Gzip Compression :-


[email protected] # gzip   -v   etc.tar

Used to compress the archive file

[email protected] # du   -sh   etc.tar.gz

Command will show the size after compression

[email protected] # gunzip   -v   etc.tar.gz

Uncompress the file


Bzip2 Compression :-


[email protected] #bzip2   -v   etc.tar.gz

Advanced Compression utility

[email protected] #du   -sh   etc.tar.gz.bz2

Command will show the size after compression

[email protected] # bunzip   -v   etc.tar.gz.bz2

Uncompress the file



Directly Creating a Compressed tar file :-

For gz compression
[email protected] # tar   -czvf    etc.tar.gz   /etc

This command will create a compressed tar file

For bz2 compression
[email protected] #  tar    -cjvf    etc.tar.bz2   /etc

This command will create a compressed tar file

The Video Below is a step by step guide.



Share on :

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *