Adding new repositories

You download and install third party packages from foreign repositories at your own risk. You must be certain that you trust the repository owner and package maintainers before you install their software.

Ubuntu is a very maintainable OS. This is especially true regarding updates and keeping configurations traceable for you and third persons (e.g. another system administrator). To make this possible, Ubuntu takes care of a strict separation of automatically created default configuration files and user-generated configuration files.

The named characteristics are realized for the Advanced Packaging Tool (APT) and it's repository lists as follows:

  • /etc/apt/sources.list is the central repository list. You should not touch this file!
    The list was created when you installed your system, enabling you to basically use your OS. Changing this file is a bad idea because it may gets overwritten when you are updating the system.
  • apt is looking for user-generated *.list files in the /etc/apt/sources.list.d/ directory automatically.
    Therefore it is possible and recommended to create a separate /etc/apt/sources.list.d/your-reposity-name.list for every repository you add. If you follow this rule, you will always know which repositories you added, making updates, clearance and troubleshooting less painful. Core utilities like add-apt-repository are following this rule, for sure.

Adding a PPA repository

PPA stands for Personal Package Archive (see terms for more information).

Adding a PPA is really easy since Ubuntu 9.10 Karmic1) because add-apt-repository does all the needed work for you:

  1. It creates a fitting .list file within the /etc/apt/sources.list.d/ directory
  2. It imports the GnuPG keys automatically

Open a terminal and use the following commands to add a PPA and update your local repository/package cache:

sudo add-apt-repository ppa:ppa-name
sudp apt-get update

If is down (happens from time to time), the key import will fail. Simply re-run add-apt-repository until it works. The program is intelligent enough to know which actions are already done and which are missing, so don't worry about problems when re-executing it.

Simple replace ppa:ppa-name with the name of the PPA you want to add. Examples:

sudo add-apt-repository ppa:foobar
sudo add-apt-repository ppa:dock-core/ppa
sudo add-apt-repository ppa:bisigi

Adding a repository

Even if you will read something like “add foobar to your /etc/apt/sources.list” very often, this is simply dirty and hard to maintain. The place for user-generated, additional .list files is the /etc/apt/sources.list.d/ directory.

  1. Make sure you got all needed information: The repository address and – if available – the ID of the GnuPG key the repository is using to sign the packages it provides.
  2. Open a new terminal
  3. Create a list file2) within /etc/apt/sources.list.d/, using your favorite editor. E.g. nano:
    sudo nano /etc/apt/sources.list.d/your-new-repository.list

    E.g. gedit:

    gksudo gedit /etc/apt/sources.list.d/your-new-repository.list
  4. Copy and paste the repository address into your editor, store the file and close it afterwards. You can use # for comments. Example:
    # See for information, GnuPG key ID is "AABBCCDD"
    deb lucid
  5. If available, add the GnuPG-Key via
    sudo apt-key adv --recv-keys --keyserver key-id

    Simply replace key-id with the correct Key-ID. If is down (happens from time to time), you may try instead.
    Even it is possible to use unsigned repositories, you should be really distrustful if the repository owner is not providing a GnuPG key. Additionally, apt-get will warn you often if there are no signatures.

  6. Update your local repository/package cache:
    sudo apt-get update

Done. Now you can install packages provided by the new repository using by using sudo apt-get install your-package

Tips and trick

Comments in .list files

The pound sign # is used within .list files to comment something out. Everything behind it will be ignored. Example:

# This is a comment about the partner repository. "deb-src" is
# commented out because I do not want to compile software.
deb karmic partner
#deb-src karmic partner

See also

1) If you are running an older version, simply add the PPA like it is described at ”Adding a repository”.
2) use an easy lowercase name, without special chars. Replace spaced through ”-” or “_”
QR Code
QR Code os:ubuntu:package-management:adding-repositories (generated for current page)
Translations of this page: