Tuesday, April 27, 2010
1:20 AM

Handling the various of packages like .tar, .tar.gz,.bin,.bundle etc

Aim: To make aware the reader how to handle various kinds of packages in linux

.tar:  Tape Archive.

A file with ".tar " extension is basically a collection of files and folders put into one package, which is some times called as a tar ball.

To get the contents out of such a file, in case of the new distros like ubuntu you can just right click on the file and select "extract here" or open using "archive manager" and extract it to where ever you want.
On command line such files are untarred using the command tar

To extract from a .tar file

syntax: tar [options]  "filename".tar

"tar" is the command to handle the ".tar" files.
General options
-x : Extract
-v: Verbose, prints on the terminal the names of the files extracted
-f:Indicating that the file name is being passed on the command line.

let us assume we have a file named "folder1.tar" which we want to untar.

For eg: 
user@Desktop:~/folder1$ tar -xvf folder1.tar
folder1/
folder1/file1
folder1/file2
user@Desktop:~/folder1$

The above example the output shows that the files that were extracted were "folder1" that had "file1" and "file2" in it. This would by default would be extracted to the present directory with the same name as the ".tar" file name i.e. "folder1".

Creating a "tar" file:

In case you have a huge set of files, with directories and subdirectories which you want to keep intact but still create a single compressed file of all the files. Then you can make use of the "tar" command.

Creating a "tar" archive retains the folder structure and when you untar the "tar" archive, all the files and folders would be untarred with exactly the same hierarchy.

For eg:

Assume we have a folder called "folder1" which has 3 folders named  "one" "two" and "three" and each of these folders in turn have a files named  "one_1", "one_2" ,"one_3" in  folder "one" .
"two_1", "two_2" and "two_3" in folder "two"
"three_1",three_2" and three_3" in folder "three"

To create a ".tar" file of the folder1 run the following command

user@Desktop:~/$ tar -cvf folder1.tar folder1
folder1/
folder1/one/
folder1/one/one_3
folder1/one/one_1
folder1/one/one_2
folder1/three/
folder1/three/three_3
folder1/three/three_1
folder1/three/threee_2
folder1/two/
folder1/two/two_3
folder1/two/two_1
folder1/two/two_2
user@Desktop:~/$

If you run the ls command now, you should be able to see a file named "folder1.tar" which is an archived file containing all the files of your folders. You can untar this file using the previously discussed command and the folder1 would appear with the three folders and the respective files in it.

options:
The options that we passed were
-c:  Create
-v: Verbose, that is why the file names were printed on the screen.
-f: To indicate that the filenames are being passed on the command line.



".tar" files are just archives and generally do not compress the size of the folders.
To compress the size you can use tools like "gunzip" or "bunzip".
That is why often you will come across files of the format

".tgz" or ".tar.gz" are ".tar" files that are compressed using the gunzip tool.
To extract them we will have to use the option "-z" with the "tar" command.


For eg:

Assume  we have a file "folder1.tar.gz"


user@Desktop:~/$ tar -xzvf  folder1.tar.gz
folder1/
folder1/one/
folder1/one/one_3
folder1/one/one_1
folder1/one/one_2
folder1/three/
folder1/three/three_3
folder1/three/three_1
folder1/three/threee_2
folder1/two/
folder1/two/two_3
folder1/two/two_1
folder1/two/two_2
user@Desktop:~/$

The command would prodcue a list of files that it is extracting. If the command executes succeefully, a folder by the name folder1 should be visible in your current directory.

Compressing a file using the gunzip:

To create a compressed file out of a tar file, we can make use of the command gzip.
For eg:
user@Desktop:~/$ gzip folder1.tar
user@Desktop:~/$ 

The above command should "zip" the .tar file into a file of the format "tar.gz".

Similar to gunzip, there is another tool that is often used for compression, i.e. bunzip.
The files compressed using bunzip are of the format ".tar.bz2".

To unzip a file compressed in the bunzip format add option "-j" to the tar commands.

For eg:

Assume we have a file named folder1.tar.bz2, which is a bunzip compressed file.

user@Desktop:~/$  tar -jxvf folder1.tar.bz2 
folder1/
folder1/one/
folder1/one/one_3
folder1/one/one_1
folder1/one/one_2
folder1/three/
folder1/three/three_3
folder1/three/three_1
folder1/three/threee_2
folder1/two/
folder1/two/two_3
folder1/two/two_1
folder1/two/two_2
user@Desktop:~/$

The output is similar to what we have seen while extracting the "gunzip" archive, a list of files being extracted.

To compress a file using bunzip we need to use the bzip2.

For eg:
user@Desktop:~/$ bzip2 folder1.tar
user@Desktop:~/$  

This will create a file of the format "folder1.tar.bz2".

.bin files:

.bin files are bascially installation files. To run the installation you need to give it execute permission. This can be done using the chmod command as follows.

user@Desktop:~/$ chmod 777 "filename"
user@Desktop:~/$ ./"filename"

.bundle files: 

.bundle files, similar to .bin files are basically installation files, which can be run as follows

user@Desktop:~/$  ./"filename"





.deb 


.deb packages are debian packages, they can be used only in debian based systems like Ubuntu or Linux Mint.

.deb packages are basically installation packages which can be installed using the following command.

user@Desktop:~/$ dpkg  -i "filename".deb 


.rpm 


.rpm stands for red hat package manager. These packages are basically installation packages used in red hat based systems. To install using this package run the following command

user@Desktop:~/$ rpm -ivh "filename".rpm 


Those the major files that we will come across in Linux.



That covers the major types of files we will come across in Linux.

0 comments:

Post a Comment