Skip to content
Search

Add-apt-repository

lastmod 2025-02-13created 2019-01-2514 edits

Adds a repository into the /etc/apt/sources.list or /etc/apt/sources.list.d or removes an existing one.

SYNOPSIS

add-apt-repository [OPTIONS] REPOSITORY

Options

-h, --help
Show help message and exit
-m, --massive-debug
Print a lot of debug information to the command line
-r, --remove
Remove the specified repository
-y, --yes
Assume yes to all queries
-u, --update
After adding the repository, update the package cache with packages from this repository (avoids need to apt-get update)
-k, --keyserver
Use a custom keyserver URL instead of the default
-s, --enable-source
Allow downloading of the source packages from the repository

How it works

If you specify a regular repository, it is saved to /etc/apt/sources.list.

The PPA format (ppa:<user>/<ppa-name>) is expanded into the full deb line of the PPA, and a new file is added to the /etc/apt/sources.list.d/ directory. The GPG public key of the newly added PPA is also downloaded and added to apt's keyring.

How to install the package

To be able to use add-apt-repository you may need to install software-properties-common:

export DEBIAN_FRONTEND=noninteractive  # 필요하다면 ...
sudo apt update
sudo apt install software-properties-common

Manually update

If you want to add the GPG Key manually, navigate as follows on the PPA repository site. (Reference: How do I fix the GPG error “NO_PUBKEY”?)

Technical details about this PPA > Signing key > keyID

Copy the URL and enter it as follows.

$ curl -sS "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x8CF63AD3F06FC659" \
    | sed -n -e '/BEGIN PGP PUBLIC KEY BLOCK/,$p' \
    | sed -n -e '1,/END PGP PUBLIC KEY BLOCK/p'   \
    | sudo apt-key add -

After that, add the repository URL as follows.

$ echo "deb http://ppa.launchpad.net/jonathonf/ffmpeg-4/ubuntu/ bionic main" | sudo tee /etc/apt/sources.list.d/jonathonf-ubuntu-ffmpeg-4-bionic.list

Finally, update.

$ sudo apt-get update

How to add a PPA

Add it using the shorthand form as follows.

ppa:<user>/<ppa-name>

Examples

apt-add-repository 'debhttp://myserver/path/to/repostable myrepo'
A complete apt line in quotes
sudo apt-add-repositoryhttp://extras.ubuntu.com/ubuntu
Repository URL and area in quotes (default is 'main')
sudo apt-add-repository 'http://myserver/path/to/repomyrepo'
sudo apt-add-repository 'https://packages.medibuntu.orgfree non-free'
sudo add-apt-repository 'deb [arch=amd64]https://repo.mongodb.org/apt/ubuntubionic/mongodb-org/4.0 multiverse'
multiverse - the given distribution component is enabled for all sources.
sudo add-apt-repository --remove 'deb [arch=amd64]https://repo.mongodb.org/apt/ubuntubionic/mongodb-org/4.0 multiverse'
Remove an added repository
echo "debhttps://apache.bintray.com/couchdb-deb$(lsb_release -cs) main" | sudo tee -a /etc/apt/sources.list
How to add it manually

See also

Favorite site

author Zer0 sitemap