How to Add Repositories to Ubuntu Server

Ubuntu is well known for being one of the most popular Linux-based desktop operating systems, but it is also become popular for server usage as well. The highly-acclaimed cloud platform OpenStack is built around Ubuntu, and many web hosts now offer it as an option for their VPS and dedicated server clients. This brief tutorial will explain how to add repositories to Ubuntu from the command line.

Presumably, if you have Ubuntu installed on a server, you will not have access to a graphical interface. Therefore, you need to know how to add repositories from SSH or directly from the console.

First, you should know where the software repository list is located. You can find it at /etc/apt/sources.list. Before you start editing it, you should make a backup copy:

sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup

Inside the file, you will find a list of repositories. Most likely you will only see the default ones, unless you have added others. To add repositories not listed, simply start on a new line and paste in the information so that it looks like this:

deb saucy partner
deb-src saucy partner

To add third-party PPAs, you can use the following command structure:

sudo add-apt-repository ppa:<repository-name>

After you add any repositories, you need to refresh the package list with:

sudo apt-get update

You can then install any packages available for your system in those repositories.