Packages and backups
The add-apt-repository command
Adds a PPA or a repository to the APT sources, or removes it. It is an Ubuntu tool.
Most useful options
-P ppa:usuario/repoAdds a Launchpad PPA and its GPG key. It also works without -P: add-apt-repository ppa:user/repo-S líneaAdds a full entry in sources.list format-c componenteRepository component. Defaults to main; it can be repeated-rRemoves the repository: comments out its line and deletes the file if only empty or commented lines remain-yAnswers yes to all questions, without asking for confirmation-nDoes not update the package cache after adding the repository-LLists the active repositories--dry-runShows what it would do without changing anything. It does not exist on Ubuntu 20.04, only in later versionsCopy-ready examples
$ sudo add-apt-repository -Llists the active repositories. It changes nothing.$ sudo add-apt-repository --dry-run -P ppa:usuario/repositorioshows what it would do with a PPA, without touching the sources.$ sudo add-apt-repository -P ppa:usuario/repositoriowarning: adds the PPA, its GPG key and updates the cache. Only do it with authors you trust.$ sudo add-apt-repository -n -S 'deb https://repo.example.org/ubuntu noble main'adds a full sources line without updating the cache.$ sudo add-apt-repository -r -c multiversewarning: removes only the multiverse component from the repositories. Without -c, -r would remove the whole repository.You can try them in the browser terminal: it does not touch your computer.
Typical mistakes
- It only adds the source: packages do not appear until the cache is refreshed. By default it does that; with -n you must run sudo apt update yourself.
- A PPA is third-party software, not reviewed by Ubuntu. Add it only if you trust its maintainer and its GPG key.
- With -r and no -c, it removes the whole repository, including its deb-src line. With -c it removes only that component.
- A private PPA also needs -l and your subscription. The Ubuntu 20.04 manual asks for the update with -u; the 24.04 one updates by default and skips it with -n.
Differences from similar commands
apt update: refreshes the package lists. add-apt-repository adds the source and, by default, refreshes them too.apt-get update: does the same refresh through apt-get. The difference is that add-apt-repository does not need you to run it afterwards.
FAQ
What is a PPA?
A personal repository hosted on Launchpad, Canonical's platform, where its author publishes packages for Ubuntu.
Does it work on Debian?
It is an Ubuntu tool, shipped in the software-properties-common package. On other distributions you can add the line by hand in a file under /etc/apt/sources.list.d/.
How do I undo it?
With sudo add-apt-repository -r -P ppa:usuario/repositorio. It comments out the line and deletes the file if only empty or commented lines remain.
More Packages and backups commands
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course