How do I install a .tar.gz (or .tar.bz2) file?

4,789,665

Solution 1

The first thing you need to do is extract the files from inside the tar archive to a folder. Let's copy the files to your desktop. You can extract an archive by right-clicking the archive file's icon inside your file browser and pressing the appropriate entry in the context menu. Extracting the archive should create a new folder with a similar name. e.g. program-1.2.3. Now you need to open your terminal and navigate to that directory using the following command:

cd /home/yourusername/Desktop/program-1.2.3

Make sure you read a file called INSTALL, INSTALL.txt, README, or something similar if one was extracted. You can check if such a file exists from the terminal by using the ls command. The file can be opened and read with the command:

xdg-open INSTALL

Where INSTALL is the name of your file. This file will contain the right steps to follow to continue the installation process. Usually, the three "classical" steps are:

./configure
make
sudo make install

You may also need to install some dependencies if, for example, running configure prompted you with an error listing which dependencies you are missing.

You can also use checkinstall instead of make install.

Remember that your mileage may vary.

Solution 2

You cannot "install" a .tar.gz file or .tar.bz2 file. .tar.gz files are gzip-compressed tarballs, compressed archives like .zip files. .bz2 files are compressed with bzip2. You can extract .tar.gz files using:

tar xzf file.tar.gz

Similarly you can extract .tar.bz2 files with

tar xjf file.tar.bz2

If you would like to see the files being extracted during unpacking, add v:

tar xzvf file.tar.gz

Even if you have no Internet connection, you can still use Ubuntu's package management system, just download the .deb files from http://packages.ubuntu.com/. Do not forget to download dependencies too.

For an easier way to install packages offline, see the question How can I install software offline?.

Solution 3

How you compile a program from a source

  1. Open a console
  2. Use the command cd to navigate to the correct folder. If there is a README file with installation instructions, use that instead.
  3. Extract the files with one of the commands

    • If it's tar.gz use tar xvzf PACKAGENAME.tar.gz
    • if it's a tar.bz2 use tar xvjf PACKAGENAME.tar.bz2
  4. ./configure

  5. make
  6. sudo make install (or with checkinstall)

Download a package from the software sources or the software center.

If you install a package via the software sources and not downloading the package on your own, you will get new updates to that package and install them via the Update Manager.

You could just install MYPACKAGE by typing in a terminal:

sudo apt-get install MYPACKAGE

or by using the software center and searching for MYPACKAGE. But if it's not there go with the source.

Solution 4

This is only for .tar.* files which have the code pre-compiled but packed into a tar file.

Okay, this is a fairly challenging task for a beginner, but just follow my instructions, and it should be fine.

First off, download the .tar.* file, and save it. Don't open it. (In these examples, I'll be installing the Dropbox Beta build, because I was going to install it anyway, so I figured that I might as well document the installation.)

After you've downloaded your file, (assuming that you saved it to Downloads,) type the following:

cd Downloads
sudo cp dropbox-lnx.x86_64-1.5.36.tar.gz /opt/

NOTE: use the name of whatever file you downloaded. (e.g., for the Firefox Nightly 19.0a1 64-bit build, you would type sudo cp firefox-19.0a1.en-US.linux-x86_64.tar.bz2 /opt/)

Now, change to the /opt/ directory, extract the program, and remove the old file:

cd /opt/
sudo tar -xvf dropbox-lnx.x86_64-1.5.36.tar.gz
sudo rm -rf dropbox-lnx.x86_64-1.5.36.tar.gz

(again, use the name of the downloaded file. Don't forget the extension.)

Okay, check to see what the extracted folder is called:

ls -a

you'll get something like this:

[email protected]:/opt$ ls -a
.  ..  .dropbox-dist
[email protected]:/opt$

Okay, in our example, we installed Dropbox, and the only folder there is called .dropbox-dist. That's probably the folder we want, so plug that in to the next step (add a / to the end, since it's a folder.):

sudo chmod 777 .dropbox-dist/

Okay, it's now marked as executable, so it's time to create a symbolic link (this is what allows you to run it from the Terminal):

sudo ln -s /opt/.dropbox-dist/ /usr/bin/dropbox

NOTE: this is sudo ln -s /opt/{FOLDER_NAME}/ /usr/bin/{PROGRAM_NAME}!!! Be sure that {PROGRAM_NAME} is replaced with the simplified, lower-case version of the program's name (e.g., for Firefox Nightly, type firefox-nightly; for the uTorrent server, type utserver. Whatever you type here will be the command that you use whenever running the program from the Terminal. Think of /usr/bin/ as like the PATH variable on Windows systems.)

Okay, you're done. The program is now installed and runnable from the Terminal.
What's this? You say you want to run it from the launcher, AND you want it to have an icon? No problem!

This part is fairly simple:

gksu gedit /usr/share/applications/dropbox.desktop

NOTE: If you're installing OVER a previous installation, use ls -a /usr/share/applications and search for pre-existing .desktop file. Plug that file's name in instead.

Now, here's where you create the icon. Here's good template; edit it appropriately.

[Desktop Entry]
Version=1.0
Name=Firefox Nightly
Comment=Browse the World Wide Web
GenericName=Web Browser
Keywords=Internet;WWW;Browser;Web;Explorer
Exec=firefox-nightly
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=/opt/firefox/icons/mozicon128.png
Categories=GNOME;GTK;Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;x-scheme-handler/chrome;video/webm;application/x-xpinstall;
StartupNotify=true
Actions=NewWindow;
[Desktop Action NewWindow]
Name=Open a New Window
Exec=firefox-nightly -new-window
OnlyShowIn=Unity;

You may want to leave off the MimeType option completely. That could be very bad if you didn't.

Now, click "Save", close it out, and you're in business!

Solution 5

First things first

It is generally not advised to download and install applications from the internet files. Most applications for Ubuntu are available through the "Ubuntu Software Center" on your system (for example, K3B ). Installing from the Software Center is much more secure, much easier, and will allow the app to get updates from Ubuntu.

That said, how to install tar packages

The best way is to download the tar.bz2 and tar.gz packages to your system first. Next is to rightclick on the file and select extract to decompress the files. Open the location of the folder you extracted and look for the Readme file and double click to open it and follow the instruction on how to install the particular package because, there could be different instruction available for the proper installation of the file which the normal routine might not be able to forestall without some errors.

Share:
4,789,665

Related videos on Youtube

Silambarasan
Author by

Silambarasan

I'm a ubuntu new user. getting lot Q?

Updated on September 17, 2022

Comments

  • Silambarasan
    Silambarasan 3 months

    I have downloaded tar.gz files. But I don't know how to install it. How do I install this kind of file?

    • Catskul
      Catskul over 7 years
      As mentioned in some of the answers below, try hard not to install packages via tarball as it will often bork managed packages and get you into in unresolvable state, and make you very sad. Installing via package manager is preferrable in 99.14159265% of cases.
    • Benny Neugebauer
      Benny Neugebauer over 6 years
      There is a helpful video on YouTube which explains it: youtube.com/watch?v=njqib0fzE9c
    • Kulasangar
      Kulasangar about 5 years
      I tried this and it worked.
    • gpaoli
      gpaoli almost 5 years
    • tgkprog
      tgkprog almost 4 years
      is this the same for ubuntu 18 or is there a UI to do it too?
    • William Martens
      William Martens about 2 years
  • Tommy Brunn
    Tommy Brunn over 12 years
    I would very much recommend using checkinstall, as that will make uninstalling the application much easier.
  • invert
    invert over 12 years
    Personally I like to put source in ~/src to keep my Desktop clutter free :)
  • William Brendel
    William Brendel over 12 years
    ..of course assuming the tarball contains some kind of source code.
  • Sergey
    Sergey about 11 years
    Well, more generic instructions would be "download the file, unpack and look for install instructions either inside or on the website".
  • Alvar
    Alvar about 11 years
    I've never got any instructions for installing from a source, I only get a folder with some install.sh or configure files. What sources do you download?
  • Alvar
    Alvar about 11 years
    @sergey is it better now?
  • Lekensteyn
    Lekensteyn about 11 years
    @Alvar: ./configure && make && sudo make install assumes that the package uses an autoconf style of configuring and compiling programs. You should search for the files INSTALL, README or similar. Also, make install won't work if the prefix is set to a privileged location (which is the default). Therefore, use sudo make install or install it into a directory in the home directory using ./configure --prefix=~/yourprogram. Then put ~/yourprogram/bin in your $PATH or make symlinks to it in ~/bin/.
  • Wut
    Wut over 10 years
    I ran tar -xvjf and then ./configure and I got an error message, see my edit in the original post.
  • Wut
    Wut over 10 years
    Yes. Also, I did that and got another error, please see my second edit in the original post.
  • Wut
    Wut over 10 years
    Could you rephrase that?
  • Rinzwind
    Rinzwind over 10 years
    you installed babl. the 1st time you got an error it ONLY complained about babl. so try to configure the 1st tarball (the one that complained about babl) it might work now.
  • Wut
    Wut over 10 years
    Oh, I see now. Judging by the tutorial you linked to in your post, I'm presuming there's a lot more I need to do, though. This is all way over my head so I guess I'll just wait for a .deb. Thanks for your help, though!
  • BuZZ-dEE
    BuZZ-dEE about 10 years
    I think this isn't a good answer, because you don't differentiate between software that you have as binary and software in source code.
  • JamesTheAwesomeDude
    JamesTheAwesomeDude about 10 years
    @invert Yeah, my Windows desktop has all kinds of stuff on it: files, programs, several old, empty folders, but when I boot into Ubuntu, my desktop is sparkling. I have all my projects in ~/sandbox/PackageName/package-x.x-y/
  • Bruno Pereira
    Bruno Pereira almost 10 years
    Think you are getting the down votes because you are not explaining what to do with most source code packed file you download. Just because dropbox came on a nice binary ready to be extracted to /opt that does not mean that every application will be delivered that way, specially since dropbox is closed source. This does not explain how to pick up a source package, build it and install it as it is.
  • foodiepanda
    foodiepanda over 9 years
    Notice that the part about k3b is because this answer was merged from another question (which, I presume, was about installing k3b from source). So if you're not trying to install k3b, don't follow that! Not saying that k3b is bad though =P
  • rightaway717
    rightaway717 over 9 years
    What does "Okay, it's now marked as executable, so it's time to create a symbolic link (this is what allows you to run it from the Terminal)" mean?
  • Wilf
    Wilf over 8 years
    Checking for READMEs etc are also useful
  • Andrea Lazzarotto
    Andrea Lazzarotto over 8 years
    That's why I wrote «Make sure you first read a file called INSTALL or INSTALL.txt or README».
  • Selah
    Selah over 7 years
    these are instructions for a specific case... a more common case I run into does not require compiling, the important information to know is where in my filesystem I should move it and how to make .desktop icon file
  • Andrea Lazzarotto
    Andrea Lazzarotto over 7 years
    Tarballs are used to distribute source code almost every time. If you have any specific example of unusual tarball, you may consider adding it as an answer and that would be a specific case.
  • AlwaysLearning
    AlwaysLearning about 6 years
    Erm.....How exactly do you download a .deb file & dependencies without an internet connection...?
  • Lekensteyn
    Lekensteyn about 6 years
    @AlwaysLearning How can you post a comment here without an Internet connection...? Try the linked "How can I install software offline" link.
  • XtrmJosh
    XtrmJosh about 6 years
    I actually largely agree with @Selah here, almost every tarball I've come across so far is compressed binaries. Source code nowadays is distributed primarily via SCM. It would be really nice to hint at potential places to extract to for binary-tarballs, as opposed to only detailing the installation of source code (which is a ridiculous thing to begin with, really, as most developers would know what to do with it).
  • Andrea Lazzarotto
    Andrea Lazzarotto about 6 years
    What kind of extremely weird tarballs do you usually download? :D
  • dessert
    dessert about 5 years
    You really should promote the use of sudo checkinstall instead of sudo make install more! It's a really good idea to manage software compiled from source via the package management, easy removal just to mention one point. For easy dependency resolving there's auto-apt, see here: auto-apt run ./configure replaces ./configure.
  • Ferroao
    Ferroao about 5 years
    sudo ln -s /opt/{FOLDER_NAME}/ etc. shoud be sudo ln -s /opt/{FOLDER_NAME}/{program real name} ? etc.
  • AlQuemist
    AlQuemist almost 5 years
    Sometimes there is actually no need for an installation. One has only to copy/move the archived files to the right folder: First, find out where the current installation resides, e.g., via which <SoftwareName>. Then move the extracted contents of tar.gz archive to that folder to overwrite the contents.
  • Selah
    Selah almost 5 years
    @AndreaLazzarotto Here is an example of a program that is delivered simply as a tarred directory, not as something that needs to be compiled. protege.stanford.edu/products.php
  • Selah
    Selah almost 5 years
    This post has a nice explanation for the situation where a tar-ed program does not need to be compiled from source: askubuntu.com/questions/6897/where-to-install-programs
  • WinEunuuchs2Unix
    WinEunuuchs2Unix over 4 years
    +1 but just wanted to comment that after 8 years someone should have written an automated bash script by now. The script would download, analyze, mkdir, un-tar, splash the README, check dependencies, compile, rm -d, report errors, etc. One could attach the script to nautilus right click. If such a script doesn't exist I may have found my next project :)
  • Adi Prasetyo
    Adi Prasetyo over 4 years
    try with sh install.sh when xdg-open doesn't do
  • Pooja Khatri
    Pooja Khatri over 3 years
    what if configure file is not present?
  • Cadoiz
    Cadoiz about 1 year
    So does cp dropbox-lnx.x86_64-1.5.36.tar.gz /opt/ unpack the archive automatically?