How to Install Software from a Tarball in Linux

Most of the time, installing software in Linux is a breeze. Package management utilities like Apt, Portage, and Yum have made software installation in Linux even easier than it is in Windows (in my opinion at least). If you know what you want, you simply tell your package manager that you want it, and it’ll find, download, install, and configure your new package for you.

Sometimes, however, the package doesn’t exist in your distribution’s repositories. Often, in cases like that, your only option is to download a tarball (usually .tar.gz, .tar.bz, or .tgz) which contains the source code for the program that you have to compile yourself. While it may be a little intimidating at first, compiling from source is normally a quick and easy process. Today, we’ll learn how.

First off, I should note that not all tarballs are the same. This guide will be assuming that the program you’re trying to install is a normal GNU-style source code collection. Most require all the steps noted below, but many skip one step or another. For the purposes of the tutorial I’ll be compiling the source code package of Python 3.0.1 from the Python homepage.

Step 1: Extract the tarball

For those new to Linux, tarball is a term commonly used to refer to a file which contains other files. It’s a lot like a ZIP or RAR file in Windows, except that the tar program, on its own, does not compress the files. Tar works with a compression program like gzip to actually compress the files, which is why you commonly see two extensions (.tar and .gz). This is sometimes abbreviated to just .tgz.

Fortunately, we don’t need to run two separate programs to extract the files, we just tell tar to run the files through gzip to decompress. You can use a graphical utility to extract those files by simply double clicking the tarball from your file manager, or you can do it from the command line with:

The options we gave tar are as follows:

  • -z to tell tar to run this file through gzip to decompress (use -j for bzip files)
  • -x to extract the files
  • -v for “verbose”, so we can see a list of the files it’s extracting
  • -f to tell tar that we’re working with a file

For easier unzipping, see the Tips section at the bottom of this page

Configure

Once the files are extracted, open a command terminal and go to the directory where the files have been unzipped. Before we can compile, we need to run the configure script. The job of the configure script is to check your system for all the software necessary to compile the program from source code into a usable binary program. It looks for things like gcc version and other tools needed to build the software. So once you’re in the directory with all the files that were unpacked from the tarball, type in

If all goes well it’ll go through a check of various parts of your system, then drop you back to the command line like below:

Running the configure script

The most common cause of errors in this step is a missing dependency. Look closely at any errors you may get to determine what package is missing.

Make

This is the real meat of the process – where we compile the source code into a runnable program. This is normally the easiest step, only requiring a single command. If the configure step completed without errors, simply type in

On a large program, this step might take a few minutes. Once done, you’ll be dropped back to the shell prompt as shown here.

Compilation stage

Technically, your program is now ready to use. Under most circumstances, however, you’ll want to run one more step so that she program can be fully installed into the correct locations for it to be run from anywhere.

Make install

All this really does is copy the now-compiled program into the system directories like /usr/bin so that it can be run from any directory without having to specify a path to the files. Since it’s copying to a directory outside your home, you’ll probably need root privileges. If the make step completed without errors, simply run

to copy the files. At this point, you’re all done! Your new program can be used like any other.

Tips

Chances are, you’ll be compiling from source more than once in your life. In fact, for those who like to use the latest and greatest software, this can be very common. To make it a little easier, open your .bashrc file from your home directory, and add the following aliases to the end:

19 comments

  1. This is great! Thanks so much for this. This ought to open a few new doors for a novice Linux user like me.

    • Thanks for the comment! Yeah when I first started out, no one ever explained this to me. I had to piece to together from README files until eventually I noticed a pattern.

      Glad I could help!

  2. Don’t forget to ensure you have build-essentials installed on your system.

    “sudo apt-get install build-essentials”

    I don’t think they are there by default.

  3. this is a very nice post, though it should read “How to COMPILE AND Install Software from a Tarball in Linux” imho. actually because that makes it an even better tutorial, which might interest even more ppl…

  4. One thing to note also about KDE 4 applications. They now require cmake to build. Instead of configure, you would simply run something like:

    cmake .
    make
    make install

  5. i like your tut’s very helpfull so let me share this one with you

    You should add to make

    make -j 9

    to have source compiled multi threaded (9 threads at same time instead of only one)

    very fast then

  6. Hi,
    Do I need to keep the compiled source in case I want to uninstall the software later on? If so, do I need to extract the tarball in some other folder rather then in the home folder?
    And, btw, how do you uninstall software that is installed like this?

    Thanks!
    John

    • Tarballs can all be different, but I can give the most likely answers to those questions.

      For starters, yes I’d highly recommend making subdirectories for each tarball you extract and compile. personally I have a Apps directory in my home where I extract all my tarballs. They normally make their own subdirectory when you extract them, so your source could would end up in /home/username/apps/nameoftarball.

      The other two questions have kinda of the same answer. Yes, you probably want to leave the source code on there because with many programs, you can return to that directory and type “make uninstall” to remove.

  7. i have tried 5 times to install and run linux instead of windows
    some how this installing the software downloaded is highly intimidating.
    so many command lines, so many places to look into

    this makes me stay in windows itself, something has to be done more to make linux still simpler OS to use than Windows..simply offering it free alone will not make it popular.

    i have nearly 9 flavours in dvds – but wondering how to go about it

    so far i have learned making a dual booting
    uninstalling and removing the grub and installing back

    but some how i am wondering cannot it be made still more simpler? why all this mumbo jumbo stuff?

    • Your question, and my response, are both addressed nearly verbatim on this page: http://www.zhyfly.org/projects/docs/html/LNW.html

      Regarding the tarballs, specifically – The developers certainly could (in most circumstances) make their software into an easily installable package (deb, rpm, etc). Often they choose not to, for two reasons:

      1) One set of source code can be compiled on any *nix machine without modification. You don’t need a dozen types of packages for every version of your program

      2) Distributing the source gives the power to the user. They can make any changes they like and have full control over the install process.

      So there are perfectly good reasons, based on the developers’ choices, to take the “mumbo jumbo” route. The main point here is that Linux is not SUPPOSED to be a Windows replacement – that’s not what it’s for. It certainly CAN be, and there are many valid reasons to choose Windows, but Linux’s flexibility is its strength, by design. I HIGHLY recommend reading the link posted above.

      • thank u for the reply and also refering to nice article that tell in general what linux is all about. i do wish to learn it thoroughly and see its usefulness. your writing is nice, straight, to the point.

    • It sounds like you are having trouble installing the operating system itself, rather than installing applications (which this article is about). I’m a Linux novice too, but I have not experienced the problems you have encountered.

      You said that you are trying to dual-boot Windows and Linux, which can be a tricky process. Instead of dual-booting, while you are learning about Linux, I would try Ubuntu Linux and use the Wubi installer, which let’s you install Ubuntu almost like it is an application in Windows, but then you get the option to boot directly into Ubuntu when you start up the computer. It is really easy and nice, and it makes installation a snap. No grub, no partitions, no formatting, no command lines, no master boot records, etc.

      I believe that Linux Mint (which is an Ubuntu-based distribution) has something similar to Wubi, and Linux Mint is even easier for novices than Ubuntu .

      If you decide you want to make Linux your primary OS, you can always set up a separate partition later.

      • thank u for the reply and explaining. i do have the distros u mentioned. as i am usinging windows like all, from the beginning, i found downloading installing something from the net is easy than in linux. i agree i need to apply my mind more thoroughly and see where i miss the link.

        even in windows, i see, many users still have not tried all the features available there. Linux is like buying a fabric and getting it stiched to your needs and windows is like ready made dress.

        i enjoyed reading both replies and others queries too. it helps.

        once again thank u all.

  8. I just installed Ubuntu how can i install VLC 1.0.5.tar.bz2 using command line please reply as quick as possible

  9. I am using fedora 12. I am new in Linux world. I extract the VLC from its folder and then i run this ./configure command but it give me an error. Can anyone help me out………..

    ./configure
    checking build system type… x86_64-unknown-linux-gnu
    checking host system type… x86_64-unknown-linux-gnu
    checking for a BSD-compatible install… /usr/bin/install -c
    checking whether build environment is sane… yes
    checking for a thread-safe mkdir -p… /bin/mkdir -p
    checking for gawk… gawk
    checking whether make sets $(MAKE)… yes
    checking how to create a ustar tar archive… gnutar
    checking whether to enable maintainer-specific portions of Makefiles… yes
    checking for style of include used by make… GNU
    checking for gcc… no
    checking for cc… no
    checking for cl.exe… no
    configure: error: in `/home/vikas/vlc’:
    configure: error: no acceptable C compiler found in $PATH
    See `config.log’ for more details.

    • Sorry for late reply.

      Before I answer your question, I should say that you probably don’t NEED to install VLC like that. Fedora comes with a package tool that should install VLC and other common programs much more easily than using this tarball method, you only normally need this for very new or somewhat uncommon software. It’s been a while since I’ve used Fedora, but as I recall it uses “yum” to fetch packages, so try

      sudo yum check-update
      sudo yum install vlc

      and that should do it.

      As for your actualy question, it’s telling you it doesn’t have a C compiler, which is GCC. The easiest way to instal that is also with yum.

  10. This article was very helpful to me. Many thanks, as I feel I have just taken another big step forward.

Comments are closed.

Sponsored Stories