how to install tarball (.tar.gz or .tar.bz2) files in linux or unix

Quite a lot of the software, especially open source software available on the Linux and Unix platforms are distributed as a tarball. A tarball is a file that is compressed and archived using tar and a compressor such as gzip or bz2. These files usually have a file extension such as .tar.gz or .tar.bz2 or something similar. This is the most common archive format used to ship or distribute both source code as well as installable programs.

Most of the common distros do have some mechanism of downloading and installing these files that shields you from the trouble of having to install tarballs manually. But sometimes, a particular version or a specific software cannot be found in the distro repository, which means you will need to download and install tarball files manually.


The first in the process is to extract or un-compress the archive file that you downloaded. Most often they are either in .tar.gz (or .tgz) format or in .tar.bz2 (or .tbz2). There are other archive formats available but are less commonly used for software installation packages.

tar xzf software-package.tar.gz


tar jxf software-package.tar.bz2

The above command will extract the contents of the archive into the current folder as a sub directory by the same name as the archive or something very similar. Let us assume that the sub folder name is software-package. Now change directory into this sub directory, where the files are.

cd software-package/

Inside this folder you will find files called README and INSTALL. Sometimes, there will only be one or the other. Either way, go ahead and read both the files and check the installation instructions. Make sure that there are software specific steps or build options. If there are any specific instructions in these files, then that takes precedence over the installation instructions on this page.


Next steps is the configuration of the package, in order to build. This step does all the checks for the required packages. If one or more of the required package is missing, then you will need to install them first. Also, this step where you will specify any of the installation related options.

./configure --help

This will give you all the options that are available to you for this package. A common option is the installation prefix that specifies where the package needs to be installed. In most cases, you can stick with the defaults for your system. You can specify a installation prefix, if needed using the –prefix argument to the configure command.

./configure --prefix=/opt

Otherwise, just run configure without any arguments.


When the configuration finishes, be sure to go through the output and check for any errors that have been printed out. Most often the error, if any refers to the dependent package or libraries that are not found on the system. You will need to manually install these dependent libraries using this same process.


If the configuration is successful, the next step is to compile the source code to create binary files that can be installed on your machine. This is pretty easy to do with the simple make command. But this is also the part where you are most likely to run into issues if they are any.


This will likely take a while and will compile the entire package and create the installable binaries. Make sure that the compilation completes with out any errors. You might see plenty of warnings that you can ignore.


Once you have successfully compiled and build the binaries, you can now install them on your system. On most systems, you will need superuser permissions to do so.

sudo make install

The above command will now install the binaries to the appropriate locations on your system. You are all done, and you should now be able to run the software you installed. If you just wanted to install tarball, then you are done otherwise see how to clean up and/or uninstall below.

Clean up

This is mostly an optionally step. Once you have installed the software you probably do not want to keep the downloaded package and the compiled binaries around. This can save some space on your hard drive. If you just want to remove everything, then go ahead and delete everything using your favorite file manager.

bash$ cd ..

bash$ rm -fr software-package.tar.gz software-package/

If for some reason you plan to keep the extracted source around so as to recompile and install later, then you can save some space my running a clean on the folder to clean out the compiled binaries.

bash$ make clean

You might also want to keep around the source just in case you want to uninstall the installed software. Having the source around from where you installed makes it way easier to uninstall.


In order to uninstall the software, again change into the extracted software package. Now, run the make command with the uninstall option instead of the install option. As in the case of installation, you might need root or super user permissions to do so.

sudo make uninstall

The one caveat in the uninstallation is that not all programs support it. You should be able to find that out if you read the README file.

The above steps works in most cases, but does not mean it will work for all tarballs. The tarball needs to follow the GNU style source code format for these generic steps to work. Otherwise your best bet is to follow the instructions in the INSTALL or README files or the instructions from where you downloaded the package.