Installing Applications

ThistleWeb's picture

This post is aimed at helping new Linux users start to find their feet with some of the differences in the way things are done in Windows compared to Linux. My screenshots all come from Linux Mint7 XFCE CE, which is fully compatible with Ubuntu 9.04 Jaunty, so the same applies. All mainstream Linux distros suitable for newbies will have a very similar approach although the exact tools may vary slightly.

Software Repositories

Windows users are used to putting a CD in, or going to a website to download an .exe file and double clicking on it to install an application. In the Linux world we have something much more elegant and much more fun. We have repositories or "repos" for short. This should always be your first place to look for new applications you hear about and want to try.

Linux Mint & Ubuntu repository listThink of these as warehouses full of shelves, where you can go round and pick what you want from under one roof and install them in one go. Another analogy would be like the Apple App Store, where you can browse for stuff you want, click to add them to your cart and check out when you're ready. The difference is that the repos are free of charge, and all the applications in them are free of charge. Not only that, but the repos include all of your system files too, this is where you keep your system updated. You can also add other repos to your system to get a wider choice of software to choose from but more on that later.

You can interact with the repos via the terminal (aka the command line using any app like Terminator) using the apt command or in a GUI (Graphical User Interface) with Synaptic. Before you start adding or removing applications from your system you should always sync the repos to make sure that what you see is the same as what's on the server. Think of it like syncing manifests. That way your package manager will spot the differences and offer them to you. If Firefox has been updated it'll tell you. If a new version of gPodder has appeared in the repos it'll tell you.

Running As A User, Not As Root

Windows users are "administrators" by default, which means that anything they do runs with admin privileges. This also extends to anything a website script manages to execute. The system does not check, ask or care if a script executed it or you did. This is a large part of why Windows is the malware magnet that it is. Linux and UNIX by contrast runs as a user by default. The functions of "user" and "root" (the UNIX / Linux term for admin) are firmly separated all the way through the stack. This means that when you try to do some root / admin task like installing an application it won't let you as a user. It will instead prompt you for authorization. It requires you to go into temporary root mode for that function. After completing that function, you close that window and you're back to being a user again.

Note that root mode only applies to THAT function, the rest of your open windows and applications are still in user mode. This stops any script installing without your knowledge or consent. It also stops someone else with access to your PC installing unless they know the password. This does not apply only to installing or uninstalling but every administration feature you can think of from blocking domains (family filter) to applications people can run.

The CLI Method AKA "The Terminal"

Linux distros vary on how they do this. Traditionally the command has been su (Switch User), which if used on it's own will switch to the root user (if you enter the root password). Many Linux distros use the su method, which requires the user / admin to remember two passwords; their user password and the root password. The Ubuntu family have went a different route and used sudo (Super User DO) which uses the users password and has no separate root account / password. The advantage of this is only one password to remember.

The disadvantage is that unless you tell it otherwise in the sudoers file (not in the scope of this guide) any user will be able to admin the system. Since this guide is about Ubuntu and it uses sudo, we'll follow that from now on. Often when seeking help in a Linux forum, IRC (Internet Relay Channel aka a real time chat room) or blog post you'll be given a command to enter into the terminal as a solution. At first this can be intimidating, when you're used to being told "click on start, then onto control panel, look for mouse options" etc There's a few reasons why being given a command is much more efficient and elegant than a description.

  • Every Linux is different, from the choice of DE (Desktop Environment) to the applications installed. The command line is universal.
  • It's much quicker than a long set of descriptive instructions.
  • It can give errors or list problems in the terminal that may not show if you follow a GUI (point & click) solution. This helps narrow down further how to fix something.
  • Many Linux guru's do a LOT in the cli (Command Line Interface AKA The Terminal) so that's where their knowledge lies.

You can simply copy and paste a command into the terminal and hit enter but not always. Sometimes you will have to edit things like /home/rachael/ to /home/gordon/ so they fit your requirements. It's also not good practice to just copy and paste blind ie you don't know what the command is going to do. Some forums have had malicious commands posted to get people to hose their systems, although in most cases the admins of these forums remove these posts very quickly and punish the members who post them. So try to get your solutions from a trusted forum, where other members also report success.

Any command starting with sudo is going to run as root, so pay particular attention to that. As I stated earlier Linux / UNIX is very good at user / root separation so most things you'll be doing will run just fine as a user. If in doubt run the command without the sudo part. It may tell you that it needs to be root to run it, this is fine. Then you know you need to start the command with sudo. It's also worth noting that sudo gives a timed window of assumed root privilidges. This means that if you run one sudo command, followed by another root command without sudo within (I think) 5 minutes of the first, it is still in temporary root mode and will still run as root. It is good practice to put sudo in front of every command that needs it.

If you need to do a prolonged root session start with sudo su to bump the terminal into root mode. This will mean you don't have to keep entering sudo on every command. First sync the repos:

sudo apt-get update

If there are updates to receive you can follow up with:

sudo apt-get upgrade

To install an application from the terminal:

sudo apt-get install application-name

To uninstall an application from the terminal:

sudo apt-get remove application-name

You can install or remove multiple applications with one command by adding a space between each name too, to save you time doing them one at a time:

sudo apt-get install application1 application2 application3

It's worth noting at this point that Linux has a feature called Tab Complete, which helps finish off commands or paths for you, so in the above example if the repos know about "application1" "application" and "application3" you could type:

sudo apt-get install applic

Then hit Tab and see it fill itself in to:

sudo apt-get install application

Now because there's 1, 2 and 3 it does not know which one, so you add that part yourself. This can be a real time saver. It also applies in the IRC channels for nicks. Many package managers in Linux will handle dependencies for you. A dependency is another application it needs to run. So a PDF reader may need a separate lib (library) file to be able to print that pdf file to a printer. If that lib file is already installed on your PC, it knows, if it is not, then it's a dependency and will tell you it needs to install libpdfprinter (invented filename) and will install it automatically. In some cases when you remove an application it leaves behind dependencies it no longer needs, you can remove these in one swoop without having to know which apps installed them by:

sudo apt-get autoremove

It will list them and offer to remove them for you. You can chain these together with the && command if you like. The && instructs the PC to run one command after the other so:

sudo apt-get update && sudo apt-get upgrade && sudo apt-get install firefox-3.5 gpodder && sudo apt-get remove terminator

This command would (in order):

  1. Resync the repos.
  2. Update all the changes on your system.
  3. Install Firefox 3.5 and gPodder.
  4. Remove Terminator.

The GUI Method

Synaptic Package ManagerIn Ubuntu the application Synaptic is used for all of this. It's a front end application for Apt. The process is the same as above, but done with buttons.

  • Refresh = Syncing the repos.
  • Mark All Upgrades = Selects all available updates (this is grayed out if none are available).
  • Apply = Applies the changes (go to the checkout).

To search for applications:

  • Search = Type a keyword in, it'll return anything it has which matches the name or description.

Right Click (these will vary depending on the status of the application):

  • Unmark = Deselects something which has been selected (removes it from your basket).
  • Mark For Installation = Speaks for itself (adds it to your basket).
  • Mark For Re-installation = Sometimes an application fails to install properly, you can reinstall with this command (more on this below).
  • Mark For Upgrade = Speaks for itself really. Using the "Mark All Upgrades" button will automatically mark all, but this allows you to manually select only what you want.
  • Mark For Removal = Used to uninstall an application and leave behind the configuration files in case you plan on installing it again.
  • Mark For Complete Removal = Uninstalls an application and takes the configuration files with it.
  • Recommended & Suggested = Additional applications or features which add extra function to the application in question. These are not necessary.

Simply right click on any application you like the look of and "Mark For Installation" then search for the next application and repeat. When you've added everything you want click on "Apply" to install them all. Often when you do this it'll tell you it has dependencies and list them. You only need to click on "Mark", it will add them to your list automatically. There is a lot more to Synaptic than this guide but it gives a simple starter point for those new to the concept of a package manager.

So what happens if the application you're looking for is not in the repos or a newer version is available than the version in your repos? Your next step whould be looking for new repos to add (adding new shelves to the warehouse), therefor widening your choice of applications to install.

Ubuntu PPA (Personal Package Archive)

The Ubuntu PPA's are a mixed bag. In some cases the project themselves maintain one like gPodder, while others are maintained by regular users. The key here is in who to trust. If you add a PPA maintained by someone who either packages the application badly, or offers infected versions of applications, then those are the ones you'll install. Try to see if the project you want has an official PPA and use that. If not, use your judgment and the feedback of other users success or failures when using certain repos. I found there are a few VLC repos, only one of them that I tried worked.

How To Add A Repo (PPA Or Others)

The process is the same whether it's via Synaptic or the terminal. I'll only show the terminal as it's often quicker and easier.

  • Find the PPA you want to add.
  • Edit the /etc/apt/sources.list to include it.
  • Import the GPG key.
  • Resync the package manager to see the new repo.
  • Install or update your new application.

A list of repo GPG keysTo ensure that the software you get from these repos are not tampered with by malicious parties, and that they'd arrived uncorrupted we use GPG keys.

This ensures that someone can't set up a fake server to give us infected applications. We import the GPG key so it can authenticate properly. Say we want to install the latest builds of Mozilla Firefox. The Mozilla team have a "Daily Builds" PPA, so we'd search in Ask.com (I don't use Google, but if you prefer Google, by all means use it) for "Firefox Ubuntu PPA" or something similar. It will return this link to their launchpad page. We need two pieces of information from this page, the repos and the GPG key. Both command require you to be root. First open your sources.list file by:

sudo gedit /etc/apt/sources.list

Look at the Ubuntu repos already listed, you'll see whether it's Jaunty, Intrepid, Karmic etc that you need. Scroll to the bottom of the file and hit Enter to create a new line. The text on the site needs slightly modified from YOUR_UBUNTU_VERSION_HERE to jaunty so it looks like this:

deb http://ppa.launchpad.net/ubuntu-mozilla-daily/ppa/ubuntu jaunty main deb-src http://ppa.launchpad.net/ubuntu-mozilla-daily/ppa/ubuntu jaunty main

It's also good practice to add something above it to remember what the repo is for, unless it's not obvious. The # at the start of the line tells the system that it's a comment and not to be read as a command.

# Mozilla Daily Builds PPA

Save and close the /etc/apt/sources.list file. Now we import the GPG (signing) key for the repo. Note the number 1024R/247510BE. The part after 1024R/ is the key. So:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 247510BE

Mozilla Daily Builds PPA on Launchpad.netI have no idea how this command works, but it does. I got it from the "what is this" link. This also shows you how to do the same thing via the GUI in Synaptic. After adding both the repo and the key you have to sync the repos by:

sudo apt-get update

Congratulations, the contents of the new repo are yours for the installing. If it's a new application it'll be available to install, if it's a newer version of an application already in your repos you'll be able to update it by:

sudo apt-get upgrade

The other command to note here is gksu or gksudo (they both do the same). This is the command which pops up the window asking for your password to run as root. You'll have already spotted it when you ran Synaptic. The command behind that link is:

gksu synaptic

The difference is where it asks for the password, and that if you close the terminal while the sudo command is running, the application will close. So if you're running a GUI app as root, use gksu instead of sudo. You don't need a repo to install software on Linux, you can find pre-compiled binaries on websites called .deb (Ubuntu is based on Debian and uses the .deb package format) files. These are similar to Windows .exe files in that they are fully self contained.

To install a .deb file you simply double click on it which starts an application called gDebi. Again this runs as root and will check for dependencies and require your password to install. A great site for .deb files is GetDeb,Net. As with the repos, try to find one which matches your Ubuntu version. The upside of installing a .deb file is that it's quick and instant, the downside is that your package manager won't keep track of it for updates etc. You have to do that yourself. If you install via a repo, your package manager will keep track of updates along with the rest of your system.

Finally it's worth pointing out that Linux only allows one application to interact with the applications database at any one time. So if you have Synaptic running, gDebi will refuse to install, telling you that another application is accessing the database. Think of this as a single warehouse administrator, where everything in and out has to go through them. The Windows way is more a free-for-all where applications can do what they want. This is a recipe for an unstable system with a lot of cruft. This guide is meant as a starter only, to let new users who are used to the Windows way of "how a PC works" get to grips with Linux.

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer