Installing applications on Linux with apt-get
This post answers these questions:
How do I install on Ubuntu/Linux Mint/Bodhi/(a Linux based off Debian) on the command line?
How do I use apt-get?
When should I use apt-get update?
What is the build-essential package for?
I used "apt-get install <package>" as instructed. Why does my package not install cleanly?
There are several ways to install applications on Linux, depending on your distribution, but for the purpose of this particular article, I am going to focus on the Debian family, which use the apt-get utility - this includes the more popular distributions, Ubuntu and Linux Mint. The distro I use in my VMs at the moment is Bodhi, a lightweight distribution, requiring very little memory, disk space, and CPU speed.
One way to install applications is to use the application manager, but try to not use that. If you've decided to launch yourself into Linux, you should familiarize yourself with installing from the command line using the apt-get utility, as a number of programs you'll come across may require it.
APT and repositories
APT, the Advanced Packaging Tool, is a utility that helps you install applications from one or more repositories. In the most simplistic terms, the repositories are online servers that host numerous versions of a vast number of applications, and the package manager is the utility that connects to these repositories, and installs apps, also known as packages. Depending on the Linux distribution, the corresponding repository may systematically make the latest versions of applications available, or only the latest known stable and fully tested version.
For example, Fedora tends to have the most up to date applications; the repository servers are maintained by Red Hat (who make Fedora) who make these latest versions available through their servers.
The Ubuntu family however is known to be less so keen on such practices, and only publish certain versions, known to play well with their OS. Canonical maintain the servers that Ubuntu uses.
Other offshoot distributions may also use another distro's repository so long as they are compatible. Thus Bodhi, which is based on Ubuntu, uses Canonical's repository.
You may think this is hardly more than an App Store for Linux, but there's a more technical side to it - these repositories do not only hold applications, but libraries, code packages that other applications can use. Windows users are perhaps more familiar with the "missing DLL" errors, Mac users probably know they need to hunt for other apps to support the app they are trying to run.
Linux packages however also come with a list of packages they depend on. The package manager on your computer then figures out what it needs to install first, what versions and in what order, before installing the package you told it to install. It will make sure another program that uses a different version of the package doesn't mess with your first app; and when you come to uninstalling the package, it will also remove any packages that are no longer necessary in your system.
And that's very neat.
Commands
In the following text, command prompts are indicated by starting with "$>" - so if a command is listed as $> apt-get update this means to use the terminal program and run the command "apt-get update"
About sudo
You will find most commands in this article start with the word "sudo".
sudo (pronounced "soo-doo" by purists, I say it "soo-doh" like "pseudo") is a special command, which means "run the following command with root privilege." Most of the time, you are best not running any commands as root - this is a failsafe to prevent you from doing something silly, like deleting your entire system. Which, yes, you can end up doing if you're not careful. sudo tells the machine you really mean it. Before it does anything, it will ask you for either the system root password, or, if you have admin rights, your password. If you run a second sudo command soon after, it may not ask you again, depending on distro.
And so, without further ado, we come to the installation incantations!
Preparation
Before you do any installation, you will need to make sure that the apt-get utility is aware of all the latest versions, and crucially, dependencies.
$> sudo apt-get update This will update APT's dependency library, as well as updating the URLs to various package repositories to the most recent. This is a very important step, and a command you should (read: must) run before a session of installing and un-installing packages.
The very first time you're installing software, you might want to run the following command: $> sudo apt-get install build-essential This will install a number of other packages that are generally required to build applications from source, most notably the GNU C and C++ compiler suites and libraries. "./make" files, installer scripts which usually ship with source code downloaded from the web, generally depend on this.
Installing
The basic command for installing a package is $> sudo apt-get install <package> where you replace "<package>" with the name of what you want to install. For example $> sudo apt-get install abiword to install the AbiWord package. To install a specific version of a package, specify it after an equals sign, for example $> sudo apt-get install abiword=2.4.6
You will be asked whether to proceed, after having been given a summary of what packages will be updated and how much extra space will eventually be taken on your system.
Session
In order of operation then:
On a new Linux, run: $> sudo apt-get update $> sudo apt-get install build-essential
When installing an application for the first time in the day, run apt-get update first, then start installing using apt-get install <package>.
Building from source code
If you download the source code for a package from off the web, you'll normally be given a README and a 'make' file. The Makefile as it is called contains instructions for building in various modes. Most often, simply switching to the directory and running the following will work (but please, do always read the README file first - do it the courtesy of its name!) $> sudo apt-get update $> sudo apt-get build-essential $> sudo ./make install
This also holds true if you're given an installer file - for example, the VirtualBox Guest Additions has a script for installing the VirtualBox add-ons, which requires the build-essential package to be installed. It doesn't tell you so though - instead, it advises that it couldn't find gcc (the C compiler).
Updating your OS
From your old Windows or Mac OS X habit, you might be tempted to upgrade from one version of your Linux distro to the newest when it comes along. The general advice across the community is: don't. Not unless you are running an experimental system you don't mind losing.
From the Linux Mint upgrade notes: "Unless you need to, or unless you really want to, there's no reason for you to upgrade." This is an important concept of Linux distributions in general.
Linux versions come with newer interfaces, might add new file system support, and various other features - but rarely anything so ground-breaking that you'd be left behind if you didn't update.
For more on the topic, check the Linux Mint Community pages on the topic.
Conclusion
That's the end of the tutorial. Have fun installing lots of fun apps - take a look at this list for a start, and happy installing!



















