Monday, March 2, 2015

How to create and extract tar, tar.gz, tar.bz2 files on Lubuntu


In this article i will show you how to create and extract tar, tar.gz, and tar.bz2 files on lubuntu. If you are looking for tutorial about how to zip and unzip on lubuntu, please read my other article.

Before we begin let me explain little bit about tar and all the variations (tar.gz, tar.bz2). Tar is the name of the compression format (like zip/unzip) as well as the name of the program.

The word 'tar' is derived from 'tape archive', is a very popular compression format on linux, therefore learning how to use it is a must for every linux users.

How to create tar file

tar -cvf [archive_name.tar] [name_of directory]
example :
tar -cvf myfolder.tar ~/Documents/
tar -cvf picture.tar ~/Pictures/

How to extract tar file

tar -xvf [archive_name.tar]
example :
tar -xvf myfolder.tar
tar -xvf picture.tar
extract on different directory :
tar -xvf myfolder.tar -C /tmp/
tar -xvf picture.tar -C ~/Downloads/

How to create tar.gz file

tar -zcvf [archive_name.tar.gz] [name_of directory]
example :
tar -zcvf myfolder.tar.gz ~/Documents/
tar -zcvf picture.tar.gz ~/Pictures/

How to extract tar.gz file

tar -zxvf [archive_name.tar.gz]
example :
tar -zxvf myfolder.tar.gz
tar -zxvf picture.tar.gz
extract on different directory :
tar -zxvf myfolder.tar.gz -C /tmp/
tar -zxvf picture.tar.gz -C ~/Downloads/

How to create tar.bz2 file

tar -jcvf [archive_name.tar.bz2] [name_of directory]
example :
tar -jcvf myfolder.tar.bz2 ~/Documents/
tar -jcvf picture.tar.bz2 ~/Pictures/

How to extract tar.bz2 file

tar -jxvf [archive_name.tar.bz2]
example :
tar -jxvf myfolder.tar.bz2
tar -jxvf picture.tar.bz2
extract on different directory :
tar -jxvf myfolder.tar.bz2 -C /tmp/
tar -jxvf picture.tar.bz2 -C ~/Downloads/


~ cheers ~

No comments:

Post a Comment