Package management

2.3.2. Package management#

When you were looking through the menus before, you saw that by default, Ubuntu comes with a single application for all the common tasks you can do. How very much unlike the free software spirit! Of course, a great many applications are available for each task, but the Ubuntu people have selected only a small subset suitable for regular users. All other software can be installed using the package manager, which in Ubuntu is called Ubuntu Software.

Exercise 2.5

Use Ubuntu Software (you can find it in the Dock or using the Apps button) to find out how many web browsers you can install.

A package contains all the files that belong to a specific piece of software. But remember that people like to build on each other’s work. To avoid having to install many copies of the same basic library, it comes in its own package, on which the other packages depend. Thus, when you install an application, the package manager not only downloads and installs that application’s package, but also all its dependencies (and their dependencies, etc.). Ubuntu Software hides all this complexity. We can use another graphical package manager, called Synaptic, which hides less, so it’s easier to see what’s going on.

Exercise 2.6

Use Ubuntu Software to install the Synaptic Package Manager. What happens when you click the Install button?

Exercise 2.7

Use the Synaptic Package Manager to find out more about its package.

(hint: search for synaptic, find the package in the results, select it, and then click Properties). You can see exactly which libraries it depends on, and which files are installed.

2.3.2.1. Repositories and PPAs#

All software that you can install using the package manager is downloaded from online distribution shares called repositories. A repository is essentially nothing more than a collection of files (called Debians in Debian Linux and Ubuntu), organized in a certain way that the package manager understands. The USB stick you can use to install Ubuntu from in Section 2.11.2.2 is in fact a bootable repository of sorts[1]. Whenever you install something with Ubuntu Software or through synaptic, the package manager uses its information on all available packages (something called the index), downloads the necessary files and installs them.

Although it may seem like the Software Center contains all the software that is available for us to install, this is not true: it is fairly easy to add additional repositories to the list accessed by the package manager, allowing us to install software that is not available otherwise.

Exercise 2.8

Ubuntu itself comes with a default list of repositories it uses, but some are disabled. Open synaptic, then use Repositories under Settings to enable the Universe repository. Now switch to the Other software tab and scroll through the list. Do you recognize the installation medium you used? Which repositories are on there?

Close the dialogue using the Close button, and acknowledge the fact that the package manager now needs to reload its index, in order to update its local knowledge of available packages.

Software repositories may not only be managed by big companies or organisations. Ubuntu enthusiasts can create what are called Personal Package Archives, or PPAs. These mini repositories may contain anything from completely new software written by someone in their spare time, to updates to Ubuntu that Canonical (the company behind Ubuntu) won’t release. Adding a PPA is as simple as adding any other repository, and can be done through either the command line, or the GUI of synaptic[2].

In the next exercise, we’ll add a PPA to your installation that gives us access to the latest versions of the popular version control tool Git, which will be of use in later modules.

Exercise 2.9

Open https://launchpad.net/~git-core/+archive/ubuntu/ppa in a browser, this is the main site of the Ubuntu Git Maintainers team. Now locate the URI of the PPA on the page, under Adding this PPA to your system. For this PPA, it should be ppa:git-core/ppa. To add the PPA to your system, go back to the Other software tab in synaptic (see Exercise 2.8), and click Add. Now paste the URI into the textfield, and click Add Source. Close the dialogue and acknowledge that we need to update. Now reload the index and search for git. What is the latest version that we can install?

Adding a PPA can also be done using the command line[3]. In the following exercise, we’ll add the Git PPA again, but with the help of the add-apt-repository command. Note the use of sudo, as explained in Section 2.3.1.1.

Exercise 2.10

Open a terminal with Ctrl+Alt+t and enter the following command:

sudo add-apt-repository ppa:git-core/ppa.

Press Enter.

The command will ask you whether you really want to add the PPA — this is where you can make sure that you are adding the correct PPA — Press Enter again if you are, or Ctrl+c to abort. You’ll be shown some confirmation messages, and a final OK, telling you that the import was successfull.