add-apt-repository
Add a new APT software repository
TLDR
Add a new apt repository
Remove an apt repository
Update the package cache after adding a repository
Allow source packages to be downloaded from the repository
SYNOPSIS
add-apt-repository [options] repository
PARAMETERS
-r, --remove
Remove the specified repository
-y, --yes
Assume yes to all queries automatically
-n, --no-update
Do not run apt update after adding
--update
Run apt update after adding (default)
-k KEYID
Use specific key ID instead of auto-downloading
--list
List all configured repositories
-m, --mass
Mass mode for scripting multiple operations
DESCRIPTION
The add-apt-repository command is a convenience script primarily used on Debian-based systems like Ubuntu to easily add Personal Package Archives (PPAs) or other third-party repositories to the APT package manager's sources. It simplifies the process by automatically handling the addition of repository entries to /etc/apt/sources.list.d/, importing required GPG keys for repository verification, and optionally updating the package cache.
When adding a PPA, specify it in the format ppa:user/ppa-name, and the command resolves it to the full deb line, fetches the signing key from Launchpad, and configures everything. For custom repositories, provide the full sources.list line. This eliminates manual editing of sources files and key management, reducing errors.
It's part of the software-properties-common package, essential for modern Ubuntu workflows. Users rely on it for accessing software not in official repos, like newer versions of apps or drivers. However, adding untrusted repos can pose security risks, so verify sources first.
After adding, run apt update to refresh indices (enabled by default unless disabled). Removal reverses the process cleanly.
CAVEATS
Requires software-properties-common package; risky with untrusted repos as it adds keys to system trust; PPAs are Ubuntu-specific and may break on non-Ubuntu Debian; always review output before confirming.
EXAMPLES
add-apt-repository ppa:deadsnakes/ppa
Adds Python versions PPA.
add-apt-repository -r ppa:deadsnakes/ppa
Removes it.
add-apt-repository 'deb http://archive.ubuntu.com/ubuntu focal main'
Adds custom sources line.
PPA FORMAT
Use ppa:namespace/ppa-name for Launchpad PPAs; command expands to full deb http://ppa.launchpad.net/... lines and imports keys.
HISTORY
Introduced in Ubuntu 9.10 (Karmic) as part of python-software-properties package to streamline PPA usage amid growing Launchpad adoption; evolved into software-properties-common by Ubuntu 16.04; widely used in Ubuntu derivatives but absent in pure Debian.


