Ubuntu / Linux news and application reviews.

"add-apt-repository" is an Ubuntu-specific script to add or remove repositories which, among others, automatically imports the public GPG key. For more information, see its man page.

You can use "add-apt-repository" in Debian to add Launchpad PPAs however, there are a few things that you should know. Read on to find out how to use "add-apt-repository" in Debian.

Important: many Launchpad PPAs are not compatible with Debian, because the packages are built against specific Ubuntu libraries. Some Launchpad PPAs work in Debian though - for example, the WebUpd8 Java and Atom PPAs. So make sure you know what you're doing before adding a Launchpad PPA in Debian!

Using "add-apt-repository" in Debian

To be able to use the "add-apt-repository" command in Debian Wheezy and newer, you need to install the "python-software-properties" or "software-properties-common", depending on the Debian version you're using package. To simplify things, use the command below to install both packages:

Then you'll be able to use "add-apt-repository" in Debian. However, "add-apt-repository" doesn't work exactly the same in Debian as it works in Ubuntu, so here's what you need to do to use it properly in Debian.

"add-apt-repository" can be used to add PPAs/repositories in two ways:

you need to replace your Debian version with an Ubuntu version (such as "trusty" or "precise") in the PPA source list file;

it only works with Launchpad PPAs.

To add a Launchpad PPA in Debian, use the following command:

sudo add-apt-repository ppa:some/ppa

(obviously, replace "ppa:some/ppa" with the PPA you want to add)

However, if you add a PPA under this form (for example: "add-apt-repository ppa:webupd8team/java), the PPA source file will use your current Debian version (for example, "wheezy") and it won't work, because you need to use an Ubuntu version here.

To get it to work properly, after using the "add-apt-repository ppa:some/ppa" command, you need to edit the PPA source file which is located under the /etc/apt/sources.list.d/ folder, and replace your Debian version (for instance "wheezy") with an Ubuntu version - I recommend using a LTS version such as "trusty" or "precise" because non-LTS Ubuntu version are only supported for 9 months.

Here's an example. Let's say you've added ppa:webupd8team/java in Debian Wheezy (using "add-apt-repository ppa:webupd8team/java" and as a result, the /etc/apt/sources.list.d/webupd8team-java-wheezy.list file was created, which looks like this:

To make this easier, you can use sed to automatically replace your Debian version with an Ubuntu version. For instance, if you're using Debian Wheezy, you can use the command below to replace "wheezy" with "trusty" in the PPA .list file:

This command adds the repository to the /etc/apt/sources.list file and not as a separate .list file under /etc/apt/sources.list.d/

Next, you need to import the PPA GPG key. On a Launchpad PPA, you'll find the key under "Signing key" (it's below the PPA source entries - "4" in the screenshot above) - copy the key after "/" (so for the WebUpd8 Java PPA which was used as an example above, copy "EEA14886") and import it like this: