Handling (Tar/GZip) And (Tar/Bzip2) Archives In Ubuntu

December 21, 2012 | By
| Reply More

In general computing terminology tar is a word derived from tape archive. It is a file format and also a name of a program. This program is used to handle “tar” files. This format was originally created during the use of UNIX and then it was standardize by POSIX-1. This was mainly developed in such a way that it was used to write data in any sequential I/O devices. Main purpose of this was tape backup. But, tar now is mainly used to collect different files in one larger file for distribution or archiving purpose. This preserves all the original information of file like user and group wise permissions, dates and its directory structure. So, we can say “tar” is a little program that is used to store files as well as folders in archives.

Tar is generally used in Ubuntu with gzip or bzip2 type of compression programs. This helps our archive to be very smaller is size. This archives end is “tar.gz” and “tar.bz2” format. Bzip2 is the latest and one of the best compression method used in Ubuntu today. These archive files can be easily extracted by simply clicking on them from the Nautilus (File Manager). This is possible because file extensions are default set in Ubuntu. Here, we are going to have a look at some command here on how to handle these archives.

Tar files (.tar.gz)

1. To tar files

# tar cvzf file.tar.gz file1 file2 file3 …..

2. To untar files

# tar xvzf file.tar.gz

Different flags used in command are

z – for gzip, v-verbose, c-create archive, x-extract archive and f-file (Default it will use tape device)

Note: An extension .tgz is similar to tar.gz files. They are normally referred as tar balls.

Bzip2 files (.tar.bz2)

1. To pack the files

# tar cvjf file.tar.bz2 file1 file2 file3……

2. To unpack the files

# tar xjvf file.tar.bz2

Note: Here, rest all the flags are same except “j” which is used for bzip2.
So, in general tar is called a program that can extract files from any archive and decompress them if required.

If required we can also make use of other utilities available in our Ubuntu system like.

# gunzip filename.gz (Used for compressing and decompressing “.gz” files)

# bunzip2 filename.bz2 (Used for compressing and decompressing “.bz2” files)

If you want to create an archive of any folder with “tar” utility then the command would be:

# tar cvfz packagename.tar.gz foldername

# tar cvfj packagename.tar.bz2 foldername

These are some of the command line utility through which you can easily manage “tar” files and different extensions like “.tar.gz” and “.tar.bz2”. Apart from this while using “kde” in your Ubuntu you can also use graphical utility given. Name of the program to graphically handle the archives is ark K.

You can select the program from Utilities -> Ark.

Another graphical program is Konqueror; this generally treats all the archives as normal folders. You can simply click on them and open it. This will become as virtual folder and you can easily add, remove and open files like we are working in normal folder.

Filed Under : UBUNTU HOWTO

Tagged With : ,

Free Linux Ebook to Download

Leave a Reply

Commenting Policy:
Promotion of your products ? Comment gets deleted.
All comments are subject to moderation.