Saturday 31 May 2014

Installing programs on Linux

One of the main problems new Linux users have is installing programs.

In Windows, you can just double-click a .exe or .msi file and an installer will run the work for you. In Macintosh, you can double-click a .dmg file or drop it in the Applications folder (dropping it is actually pretty intuitive, if you think about it).

In Debian and Ubuntu you can click your .deb file too, and use a graphical interface which runs gdebi installer for you. (for instance, installing latexila)



[Side note: when I mention Ubuntu, most of what I say applies to it's derived distributions like Lubuntu or Mint]

However, my preferred way of installing packages is using the terminal. You can either install packages from the repositories or download them and install "manually". I'll cover both ways.

Let's assume you want to install a package and you don't know if it is in the repositories. In a terminal, type:

sudo apt-get update
apt-cache search package_name

If your desired package is available, it'll show as output. Proceed to install it:

sudo apt-get install package-name 

[Side note: Even though this post covers Debian based distributions, CentOS or Fedora have their own repositories and installers. Instead of apt-get (aptitude), they use yum, Arch Linux uses pacman, etc, but the logic is the same.]


If not, that package may be in a personal repository (PPA). You can add that PPA to your list

using:

sudo add-apt-repository ppa:someonesppa

For an example, check this previous post on PulseAudio Equalizer.

After this step you can install it by typing:

sudo apt-get install package-name

Now, let's say the package you want is not in the main repositories and there are no PPA's you can find in which your package is available, but you were able to download a .deb file and you want it to work.

My favourite way to do this is using gdebi in the terminal. Just cd to the folder where your .deb file is and type:

sudo gdebi package_name.deb

Or if your are not inside that folder, give it the path:

sudo gdebi /path/to/file/package_name

and gdebi will do it for you. If your package has dependencies you don't have installed, gdebi will solve them for you.

Another way to install .deb files is by using dpkg (you have to change to the directory where your file is, just like with gdebi):

sudo dpkg -i desired_package_name

However, dpkg will not solve missing dependencies. You might be wondering why you would use it, then. Some packages like libreoffice have to be installed by running the installer for all files inside a folder full of .deb files. dpkg will install all files iteratively (sudo dpkg -i *.deb), whereas gdebi (sudo gdebi *.deb) will try to get dependencies from the repositories instead of keep looking for packages inside that folder, so it'll fail.

[Another side note: *.deb means it'll run through all .deb files inside that folder. If you wanted to install all files whose name starts with banana, you would do banana*]

By now you should be able to install quite a few things. However, let's imagine there are no PPA's nor .deb files for you package, and you only managed to find a .tar.gz (or something similar). Don't worry, there's still hope you can get your beloved package!

It's worth mentioning that you don't install a .tar.gz file. Tarball's (as they're called) are compressed files, like .zip or .rar, but they're commonly used to distribute packages (you can store regular files in them if you want).

First things first, you have to extract what's inside:

tar zfx package_name.tar.gz

but my favourite way is to use unp, which will unpack tarballs, zips, whatever is compressed:

unp package_name.tar.gz

After extraction, what I recommend is to read the REAME or INSTALL file. They contain specific instructions you should follow. I'll give some hints, but when dealing with compressed packages, always try to follow the instructions. If the developer is kind enough, there may be an installer file which you can run (a script that will do the install for you).

If there is no such thing, run the following commands:

./configure
make
sudo make install

And by now you should be able to install software. But remember, ALWAYS read the README help files.

If this tutorial was of any help and you have suggestions to this post or my writting, feel free to comment and I'll try to reply as soon as possible ;)




No comments:

Post a Comment