Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I would like to know how to install .tar.bz and .tar.bz2 packages on Debian, please give me a complete explanation.

share|improve this question
2  
Those are archives. You need to unpack them and see for instructions inside. Usually it's ./configure, make, make install, but I'm sure someone will provide better answer to you, with links where you can learn this very basic things before you actually try to build anything –  zetah Apr 30 '12 at 14:57
3  
Depending on what you want to install, you need also to install the build-essential package and -dev packages of the libraries which are used by the software. Take care that you install to the prefix /usr/local/ (which is normally the default), otherwise you may corrupt your system. For a beginner, I suggest you strongly to restrict yourself to the available packages from Debian. The next step would be to search for already packaged software (.deb packages) and install them then by hand dpkg -i ./path/to/package.deb. Using .tar.{gz,bz2} packages, is the last and most difficult option. –  jofel Apr 30 '12 at 16:18
    
@jofel I agree with you, but some programs are not available in a .deb package and you can only install it from the source code (e.g. Firefox). –  Zignd Oct 30 '12 at 10:21
1  
Firefox is most definitely available in the repositories and rarely needs to be built from source. –  KayakJim Oct 30 '12 at 13:03
    
@KayakJim I remember that I never could install it from Debian repository. But I'm sure that it's available in the Ubuntu repository. –  Zignd Oct 31 '12 at 10:02

5 Answers 5

up vote 15 down vote accepted
+50

Firstly, according to the File System Hierarchy Standards, the location of this installed package should be /opt if it is a binary install and /usr/local if it's a from source install.

Pure binaries

These are ready to use binaries. Normally they just need to be extracted to be installed. A binary package is going to be easy:

  • sudo tar --directory=/opt -xv f <file>.tar.[bz2|gz]
  • add the directory to your path: export PATH=$PATH:/opt/[package_name]/bin

and you are done.

From sources

A source package is going to be more troublesome (by far) and through they can roughly be processed with the method below, each package is different:

  • download the package to /usr/local/src
  • tar xf <file>.tar.[bz2|gz]
  • cd <package name>
  • read the README file (this almost certainly exists).
  • most Open Source projects use autoconf/automake, the instructions should be in the README. Probably this step will go: ./configure && make && make install (run the commands separately for sanity if something goes wrong though).

If there's any problems in the install then you'll have to ask specific questions. You might have problems of incorrect versions of libraries or missing dependencies. There's a reason that Debian packages everything up for you. And there is a reason Debian stable runs old packages - finding all the corner cases of installing packages on more than a dozen different architectures and countless different hardware/systems configurations is difficult. When you install something on your own you might run into one of these problems!

share|improve this answer
2  
I made the tar command easier! You don't need to cd /opt. Instead cd to where the tarball is and use the tar -C or --directory option. –  Jess Mar 18 '13 at 15:20
    
Ah and don't forget sudo :D –  Jess May 25 '13 at 3:05

Unpack the files and then, in the directory that was created, look for a README or INSTALL file which will tell you what you need to know in order to install a package (e.g. dependencies, configuration options, commands to run etc...).

Usually it boils down to ./configure, make then make install.

share|improve this answer
3  
Note that the build will most likely fail in configure. Why? Because the source you've downloaded probably has build time dependencies you don't have installed. On Debian/Ubuntu, if the package also is available with apt, you can install these with: sudo apt-get build-dep package-name –  anonfunc Nov 1 '12 at 18:53

The standard way of doing this is:

  1. tar zxvf file.tar.gz or tar xvjpf file.tar.bz2
  2. run ./configure (./configure --help usually gives customization options)
  3. run make
  4. run make install

There is usually a README or INSTALL file that gives instructions as well.

share|improve this answer

Generally speaking, when you install tar.gz/tgz/tar/bz2 (remember, these are just compressed package files) you would need to break open the tar file (tar xvfz/tar xvfj) and then cd to the directory and run ./configure.

On some systems, you either take the defaults (/usr/local/{lib,bin,etc...} for example) as the default install location, or you might like to use /opt/local/{lib,bin,etc}.

So you would do ./configure --prefix=/usr/local and then make, make install.

It us up to you where you want to install your packages. Remember that where ever you decide to do it, you might want to add the path to your PATH shell variable so you can easily run those packages. (often export PATH=$PATH:/opt/local/bin:/usr/local/bin).

share|improve this answer

Let me illustrate this with an example, say you wish to install a package abc. The dependencies of the package abc may be identified by reading its documentation. You should resolve the dependencies(required libraries etc) prior to installation for a smooth experience.

Before a gcc 4.7.2 build the g++, m4, gawk, gcc-multilib, gmp, mpfr, and mpc must be built.

Then comes the building from source part for which the first step is always extraction. This can be done by using the tar command or by the simple GUI way. Once you have the extracted files in a folder you must browse to that folder using the cd command, for example if the contents are in Downloads then:

$cd Downloads/abc

Now you need to run ./configure. Specify the installation directory by using the --prefix= option with configure.

Firstly, according to the File System Hierarchy Standards, the location of this installed package should be /opt if it is a binary install and /usr/local if it's a from source install.

so if you are installing to the /usr/abc directory you will supply the option --prefix=/usr/abc with the ./configure instruction.

$./configure --prefix=/usr/abc

--prefix= is not the only thing you might want to specify though, you might want to supply other information for a successful compilation like the type of your system with --build=x86_64-linux-gnu for 64 bit, and --build=i386-linux-gnu for a 32 bit system. It is wise to read the README in the extracted files as it may carry the information about which options to specify with the ./configure command.

After the ./configure run the make command, and subsequently the make install. Post installation you should specify the library path, shell/environment variables using the export command.

export PATH=/usr/abc/bin:$PATH
share|improve this answer

protected by Community yesterday

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.