How to Add APT Repository in Ubuntu

When installing packages using apt, the packages are downloaded from one or more software repositories. An APT repository is a network server or a local directory containing deb packages and metadata files that are readable by the APT tools.
There are thousands of applications available in the default Ubuntu repositories, but sometimes the package you need lives in a third-party repository. The same is true on Ubuntu 26.04, which keeps the DEB822 source format introduced in 24.04 and continues to manage repository keys through /etc/apt/keyrings/.
This guide explains how to add APT repositories on Ubuntu and Debian systems using the add-apt-repository command, the signed-by method, and manual source files, and how to enable a component such as universe that is already part of your distribution.
Quick Reference
For a printable quick reference, see the APT cheatsheet .
| Task | Command |
|---|---|
Install add-apt-repository | sudo apt install software-properties-common |
| Add a repository | sudo add-apt-repository "deb [signed-by=...] URL suite component" |
| Add a repository without prompting | sudo add-apt-repository -y "deb ..." |
| Add a repository without refreshing the index | sudo add-apt-repository -n "deb ..." |
| Enable source packages | sudo add-apt-repository -s "deb ..." |
| Enable a component | sudo add-apt-repository -c universe |
| Remove a repository | sudo add-apt-repository --remove "deb ..." |
| Add a PPA | sudo add-apt-repository ppa:user/ppa-name |
| Remove a PPA | sudo add-apt-repository --remove ppa:user/ppa-name |
| Download a GPG key | curl -fsSL URL | sudo gpg --dearmor -o /etc/apt/keyrings/key.gpg |
| Update package index | sudo apt update |
| List repositories | apt policy |
Understanding APT Sources
On Ubuntu and all other Debian-based distributions, apt software repositories are defined in the /etc/apt/sources.list file or in separate files under the /etc/apt/sources.list.d/ directory.
One-Line Format
The traditional one-line format uses .list files and looks like this:
deb [signed-by=/etc/apt/keyrings/example.gpg] https://example.com/ubuntu noble main- deb or deb-src - The archive type.
debmeans binary packages,deb-srcmeans source packages. - signed-by - Path to the GPG key that authenticates the repository.
- URL - The repository address.
- Distribution - The release codename, such as
resolute(26.04),noble(24.04), orjammy(22.04). - Components - The repository categories. The default Ubuntu repositories use
main,restricted,universe, andmultiverse. Third-party repositories typically have only one component.
DEB822 Format
Starting with Ubuntu 24.04 and continuing on Ubuntu 26.04, the default repository configuration uses the DEB822 format in .sources files. This format is more readable and structured:
Types: deb
URIs: https://example.com/ubuntu
Suites: noble
Components: main
Signed-By: /etc/apt/keyrings/example.gpgBoth formats work on modern Ubuntu versions. The DEB822 format is recommended for new configurations.
Repository Authentication
Repositories provide a public GPG key to authenticate downloaded packages. The modern approach stores keys in the /etc/apt/keyrings/ directory and references them with the signed-by option in the source entry.
apt-key command is deprecated and last available in Ubuntu 24.04. Do not use apt-key add or apt-key adv to import repository keys. Use the signed-by method described in this guide instead.To add or remove a repository you need to be logged in as either a user with sudo access or root.
Installing add-apt-repository
add-apt-repository is a utility that allows you to add an APT repository to /etc/apt/sources.list.d/. It can also be used to remove an existing repository. The command ships under two names, add-apt-repository and apt-add-repository, which point to the same script, so you can use whichever spelling you remember.
If add-apt-repository is not available on your system, you will get the following error message:
sudo: add-apt-repository: command not foundThe utility is included in the software-properties-common package. To install it, run:
sudo apt update
sudo apt install software-properties-commonAdding Repositories with add-apt-repository
The basic syntax of the add-apt-repository command is as follows:
add-apt-repository [options] repositoryWhere repository can be either a regular repository entry like deb https://example.com/ubuntu noble main or a PPA repository in the ppa:<user>/<ppa-name> format.
By default, add-apt-repository also updates the package index after adding the repository. The package index is a database that holds records of available packages from all enabled repositories.
Adding a Third-Party Repository
For example, to add the Docker repository on Ubuntu, first download and store the GPG key:
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.ascThen add the repository:
sudo add-apt-repository \
"deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"$(lsb_release -cs) prints the Ubuntu codename. On Ubuntu
24.04 it prints noble, and on Ubuntu 26.04 it prints resolute.
If you are on an ARM system (for example, a Raspberry Pi), replace arch=amd64 with arch=arm64 or the architecture you use.
For a full Docker setup on the latest release, see the Docker on Ubuntu 26.04 guide.
You can now install packages from the newly enabled repository:
sudo apt install docker-ceRemoving a Repository
To remove a previously added repository, use the --remove option:
sudo add-apt-repository --remove "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"Adding PPA Repositories
Personal Package Archives (PPA) is a service that allows users to upload Ubuntu source packages that are built and published with Launchpad as an apt repository.
When adding a PPA repository, add-apt-repository creates a new file under the /etc/apt/sources.list.d/ directory and automatically downloads the repository public key. On Ubuntu 24.04 and newer that file uses the DEB822 format, so the Graphics Drivers PPA below lands in /etc/apt/sources.list.d/graphics-drivers-ubuntu-ppa-resolute.sources rather than in a .list file.
For example, to add the Graphics Drivers PPA:
sudo add-apt-repository ppa:graphics-drivers/ppaWhen prompted, press Enter and the repository will be enabled:
Press [ENTER] to continue or Ctrl-c to cancel.Once the PPA is added, you can install packages from it:
sudo apt install nvidia-driver-580The apt
command will install the package and all its dependencies.
To remove a PPA, use the --remove option:
sudo add-apt-repository --remove ppa:graphics-drivers/ppaCommand Options
The examples above rely on the default behavior, but add-apt-repository takes a handful of options that matter once you script the work or add several repositories at once.
-y,--yes- Assume yes to all queries. Use it when the command runs unattended, such as in a provisioning script or a Dockerfile.-n,--no-update- Skip the package index refresh that normally follows, which is useful when you add several repositories in a row and want to runsudo apt updateonce at the end.-s,--enable-source- Enable the matchingdeb-srcentry as well, so you can pull source packages withapt source.-c,--component- Choose which components to enable for the repository. Without it,add-apt-repositorydefaults tomain.-U,--uri- Add a repository given as a plain URI instead of a fulldebline.-r,--remove- Remove a repository, as shown above.
Combining -y and -n is the usual pattern when you add more than one repository, because it skips both the prompts and the redundant index refreshes:
sudo add-apt-repository -y -n ppa:graphics-drivers/ppa
sudo add-apt-repository -y -n ppa:git-core/ppa
sudo apt updateEnabling a Repository Component
Ubuntu splits its own archive into the main, restricted, universe, and multiverse components, and Debian splits its archive into main, contrib, non-free, and non-free-firmware. A package is sometimes missing not because the repository is absent, but because the component that carries it is switched off.
To enable a distribution component, pass it with the -c option and omit the repository. add-apt-repository then adds the component to the distribution sources you already have, so no third-party repository file is created.
To enable the universe component on Ubuntu, run:
sudo add-apt-repository -c universeOlder examples often use sudo add-apt-repository universe. This shortcut still works through positional repository detection, but that interface is deprecated. The explicit -c form is clearer.
On Debian, use the same option to enable contrib or non-free:
sudo add-apt-repository -c contribTo enable several components at once, repeat the option:
sudo add-apt-repository -c contrib -c non-free -c non-free-firmwareThe change is written to the distribution source file, which is /etc/apt/sources.list.d/ubuntu.sources on Ubuntu 24.04 and newer, and the package index is refreshed afterwards. If apt reported that it was unable to locate a package earlier, search for it again once the component is enabled.
Manually Adding Repositories
If you want more control over how your sources are organized, you can manually create repository files. This is the recommended approach for third-party repositories.
Using the One-Line Format
Create a new .list file under /etc/apt/sources.list.d/. For example, to add the Kubernetes repository:
First, download the GPG key:
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.36/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes.gpgThen create the repository file:
echo "deb [signed-by=/etc/apt/keyrings/kubernetes.gpg] https://pkgs.k8s.io/core:/stable:/v1.36/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.listUsing the DEB822 Format
On Ubuntu 24.04 and newer, including Ubuntu 26.04, you can use the DEB822 .sources format. For the same Kubernetes repository:
sudo tee /etc/apt/sources.list.d/kubernetes.sources << 'EOF'
Types: deb
URIs: https://pkgs.k8s.io/core:/stable:/v1.36/deb/
Suites: /
Signed-By: /etc/apt/keyrings/kubernetes.gpg
EOFAfter adding the repository, update the package index and install the packages:
sudo apt update
sudo apt install kubelet kubeadm kubectlRemoving a Manually Added Repository
To remove a manually added repository, delete its .list or .sources file and update the package index:
sudo rm /etc/apt/sources.list.d/kubernetes.list
sudo apt updateListing Enabled Repositories
To see every repository that APT currently pulls from, together with the priority assigned to each one, run:
apt policyPackage files:
100 /var/lib/dpkg/status
release a=now
500 https://download.docker.com/linux/ubuntu resolute/stable amd64 Packages
release o=Docker,a=resolute,l=Docker CE,c=stable,b=amd64
origin download.docker.com
500 http://archive.ubuntu.com/ubuntu resolute/universe amd64 Packages
release v=26.04,o=Ubuntu,a=resolute,n=resolute,l=Ubuntu,c=universe,b=amd64
origin archive.ubuntu.comThe number in the left column is the pin priority, and the c= field names the component. The output above tells us that the Docker repository and the Ubuntu universe component are both enabled.
What apt policy does not show is which file each entry came from, and that is what you need before disabling or deleting a repository. Read the source directory instead. Modern Ubuntu mixes .list and .sources files in the same place, so match both and drop the comments and blank lines:
grep -rvE '^\s*(#|$)' /etc/apt/sources.list.d/Every line of output is prefixed with the file it came from. On systems that still keep entries in /etc/apt/sources.list, add that path to the command as well.
Troubleshooting
sudo: add-apt-repository: command not found
The software-properties-common package is not installed. This is the normal state on minimal server images and container base images, which ship without it. Install it with sudo apt update && sudo apt install software-properties-common. Inside a Docker image you will usually need curl and ca-certificates too, otherwise the key download in the next step fails.
W: GPG error and NO_PUBKEY
APT reached the repository but has no usable public key to verify its package list, so it refuses the metadata. Check that the Signed-By path exists and points to the provider’s current key, then download a replacement into /etc/apt/keyrings/ if the key is missing or outdated. APT still reads trusted.gpg and files under trusted.gpg.d when an entry has no Signed-By setting, but those global keyrings are not recommended for new repositories.
E: The repository does not have a Release file
The URL or suite may be incorrect, the repository may not support your Ubuntu release, or it may not publish signed Release metadata. Check the vendor’s installation documentation and confirm that the codename listed under dists/ matches your Ubuntu release. If the vendor does not support your release, disable the repository and use a supported installation method. Do not substitute noble for resolute unless the vendor explicitly documents that combination.
E: Conflicting values set for option Signed-By
The same repository is defined twice with different keys, which usually happens when a vendor install script writes a .sources file while an older .list file for the same repository is still in place. Find both with grep -r download.example.com /etc/apt/sources.list.d/, substituting the host from the error message, then delete the stale file and run sudo apt update again.
404 Not Found on a PPA
A PPA only publishes builds for the Ubuntu releases its owner chose to target. Open the PPA page on Launchpad and check the list of supported series before assuming the repository is broken. If your release is not listed, there is nothing to install, and the fix is to remove the PPA rather than to keep retrying.
FAQ
Is apt-key still supported?
No. apt-key is deprecated and last available in Ubuntu 24.04. Use the signed-by option with keys stored in /etc/apt/keyrings/ instead.
What is the difference between .list and .sources files?.list files use the traditional one-line format. .sources files use the newer DEB822 format, which is more structured and readable. Both work on modern Ubuntu versions, but DEB822 is the default format starting with Ubuntu 24.04.
Do I need to run apt update after adding a repository?
If you use add-apt-repository, it updates the package index automatically. If you add the repository manually, you need to run sudo apt update before installing packages from it.
Can I add Ubuntu PPAs on Debian?
Technically possible, but not recommended. PPA packages are built for Ubuntu and may have incompatible dependencies on Debian systems.
Where should I store GPG keys?
Store repository GPG keys in /etc/apt/keyrings/. This directory is the standard location recommended by Debian and Ubuntu.
Conclusion
For third-party software, store the key under /etc/apt/keyrings/ and write a DEB822 .sources file that points at it with Signed-By, since a per-repository key referenced with signed-by is what replaced apt-key, and a single file per repository stays easy to find and delete later. The same instructions apply to any Debian-based distribution, including Kubuntu, Linux Mint, and elementary OS.
If you are setting up a fresh system, see the guide on upgrading to Ubuntu 26.04 for the matching distribution release.
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 1000+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page