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.
–
CatskulApr 15 at 14:49

10 Answers
10

The first thing you need to do is extracting it in a folder, let's make it your desktop. You can extract an archive right clicking on it and choosing the appropriate entry.
It should create a new folder with a similar name, e.g. program-1.2.3.
Now you need to open your terminal and then go to that directory:

cd /home/yourusername/Desktop/program-1.2.3

Make sure you first read a file called INSTALL or INSTALL.txt or README. Check if there is any of these files with the ls command, and then display the right one with:

xdg-open INSTALL

The file will contain the right indications to go on with the compiling process. Usually the three "classical" steps are:

./configure
make
sudo make install

You may also need to install some dependencies, generally after some configure error which will tell you what you are missing. You can also use checkinstall instead of make install.
See here https://help.ubuntu.com/community/CheckInstall

@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/
–
JamesTheAwesomeDudeDec 17 '12 at 16:44

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.

@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/.
–
LekensteynNov 19 '11 at 10:14

1

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
–
MiJynJun 27 '13 at 2:01

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.

It is difficult to answer specifically, as each software may have a different build process, even if they are archived as a TAR/GZ

What I can say for most source codes that I know of is that you will first need to extract the tarball archive into a folder of your choice. Then most source codes rely on the AUTOCONF and MAKE programs, so you will need to use the following commands :

./configure
make

To build your binaries, and then :

make install

To install it in the system.

"./configure" uses the autoconf mechanism to retrieve information on your system, and prepare the build scripts in the source file in order to build the appropriate binaries compatible with your installation.
"make" will invode the build itself, that will create the binaries out of the source code.
"make install" will then copy the binaries, documentation, configuration file, etc. into the appropriate folders of your system so that the software is available to the users.

It is a very basic explanation, the real answer is : read the documentation provided with the source code... Only there you will know exactly how to build it.

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.xxx 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:

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.

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.
–
BuZZ-dEEOct 14 '12 at 23:14

1

Wow, what's up with all the downvotes? I remember being new to Ubuntu; I would have given body parts, computer parts, or both for a tutorial like this...
–
JamesTheAwesomeDudeOct 14 '12 at 23:19

1

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.
–
Bruno PereiraDec 26 '12 at 0:17

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?
–
user25656Jul 23 '13 at 12:33

You should always try to install software from repositories whether it's official, a PPA/any other unofficial repository. That way, you'll get all stable release, security and new feature updates while you install other system updates. Another advantage is that you don't need to worry about building, dependencies and harder uninstallation (since the application won't appear in synaptic) with tar files.

For example, you can install mysql by installing mysql-server package.

If you really want to use tar files, the common process is to run (make install may require sudo):

./configure
make
make install

Please note that some of the above commands may not be necessary, please refer to any readme files in the tar file or try to run ./configure --help

Files with the extension tar.bz2 are what is commonly known as a compressed tarball.
Other examples are .tar.gz (more common) and .tgz.

You can extract this file with...

tar -xvjf file.tar.bz2

This will extract the files from the tarball into the directory you are currently in and should create a new directory there with in that the files from the tarball.

Short explanation on the options:

-x : extract

-v : verbose: show what is being extracted

-j : type of compression, in this case bzip2

-f : 'next comes the filename'

This is probably not enough though. Depending on what it is it could have a complete compiled setup and you need to cd into the new directory and start an executable. It could also contain the source to a program that you need to confire, make, make install.
Generally (ie. I would assume) it should contain a readme that explains what to do next.

Warning:

Installing software like this will NOT install any dependencies and will complain if you try to install a tarball before you installed these dependencies.
Use a website or the file itself to find out if there are dependencies and install those first. But always always always first try to find a .DEBian installation file or a link to a ppa so you can use ubuntu software center.

If you are trying to install the gimp plugins you skipped parts of the installation process mentioned in this link.

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.
–
RinzwindMay 18 '12 at 0:14

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!
–
WutMay 18 '12 at 0:23

Installing from archives(.zip tar.gz.......etc):

these archives generally conatains the source of the package. each of them generally has a different approach to install. I will be discussing a common method which will supposedly work for all of them.

general requirements:

flex

bison or bison++

python

As these archives contains the source, your system needs the required programming languages to compile and build the source. so the general requirement packages stated above may not be sufficient for you. in that case you have to install the required packages through one of the processes #1,#2,#3 (requires internet connection). you can know about the dependencies about your software in a readme file included in the archives.

steps:

open the archives with archive manager by double clicking it, then extract it.

code:

cd path-to-the-extracted-folder

inside the extracted folder look carefully....

a. if you find a file named configure then :

./configure

make

sudo make install

if the first code fails to execute then run this code before above codes:

chmod +x configure

b. if you find a file named install.sh then

code :

chmod +x install.sh

./install.sh or sudo ./install.sh (if it needs root permission)

or you can double click it and select run in terminal or simply run

N.B : sometimes there is a file, something like your_software_name.sh is found instead of install.sh. for this case you have to replace install.sh with the correct name in the previous codes.

c. if you find a file named install then

code:

chmod +x install

./install or sudo ./install (if it needs root permission)

or you can double click it and select run in terminal or simply run

d. if you find a file named make (if there is no configure file) then

code:

make

sudo make install

e. If you still can't find the required files

then it may be in a special folder (generally in a folder named 'bin'). move to this folder with cd command with appropriate path and then look again and follow the same process.