How to add repository from shell in Debian?

Debian Jessie and later (2014-)

As pointed out by @voltagex in the comments, it can now be found in the software-properties-common package:

sudo apt-get install software-properties-common

Debian Wheezy and earlier:

The program add-apt-repository is available in Debian. It's in the python-software-properties package:

sudo apt-get install python-software-properties

It was added to that package in version 0.75. The current version in Debian Stable ('squeeze") is 0.60, so it doesn't have it. The version currently in Debian Testing ("wheezy") is 0.82.7.1debian1, so it's available there.


Assuming you're running a non-ancient version of Debian (Etch or later), you can just drop a file in /etc/apt/sources.list.d/ The file name must end with .list; Debian Stretch (not yet released) will likely add .sources with a different format.

The format is the same as the main sources.list file.

The advantage is, especially if this is for some software you're distributing, you don't have to worry merging your changes into a possibly-edited /etc/apt/sources.list file (especially hard to deal with if your program is uninstalled). You can use dpkg conffile support to put the file in /etc/apt/sources.list.d/.


add-apt-repository can now be found in the software-properties-common package.