How to Add APT Repository in Ubuntu 24.04 and 22.04
Learn how to add apt repository in ubuntu 24.04 with add-apt-repository, Launchpad PPAs, modern signed-by keyrings, DEB822 sources, and repository removal.

6 min read
Learn how to add apt repository in ubuntu 24.04 with add-apt-repository, Launchpad PPAs, modern signed-by keyrings, DEB822 sources, and repository removal.
- Prerequisites and Supported Releases
- Step 1: Understanding APT Repositories, PPAs, and DEB822 Sources
- Step 2: Installing software-properties-common
The Advanced Package Tool (APT) is the package management system powering Ubuntu and Debian distributions.
While Ubuntu's default software repositories contain tens of thousands of tested, stable packages, developers and system administrators frequently need access to newer software versions, proprietary drivers, or specialized tools not included in the standard distribution archives.
Adding custom repositories allows your system to discover, download, install, and automatically receive security updates for third-party software alongside official packages.
In this guide, we walk through how to add apt repository in ubuntu 24.04 using official Launchpad PPAs, modern cryptographically verified GPG keyrings, DEB822 configuration files, and clean repository removal practices.
Comprehensive step-by-step administrator guide on how to add and manage APT package repositories in Ubuntu 24.04 LTS (Noble Numbat) and 22.04 LTS (Jammy Jellyfish). Explains the underlying architecture of software repositories, using the add-apt-repository utility for Launchpad PPAs, integrating third-party repositories securely using modern signed-by GPG keyrings in /etc/apt/keyrings/, understanding Ubuntu 24.04's new DEB822 .sources format, and removing or disabling unneeded repositories.
Prerequisites and Supported Releases
This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat) & Ubuntu 22.04 LTS. The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.
Before proceeding, ensure you have the following requirements satisfied:
- A computer or server running Ubuntu 24.04 LTS or Ubuntu 22.04 LTS.
- A non-root user account with
sudoadministrative privileges. - Basic familiarity with the Linux terminal command-line interface.
Step 1: Understanding APT Repositories, PPAs, and DEB822 Sources
An APT repository is a network server hosting compiled Debian packages (.deb) alongside index files and cryptographic signatures.
Ubuntu divides its official software archives into four main components: main (canonical-supported open-source software), restricted (proprietary drivers), universe (community-maintained open-source software), and multiverse (software restricted by copyright or legal issues).
Beyond official components, developers use Personal Package Archives (PPAs) hosted on Canonical's Launchpad to distribute pre-compiled packages.
In Ubuntu 24.04, Canonical transitioned the default package configuration from traditional one-line /etc/apt/sources.list files to structured DEB822 format in /etc/apt/sources.list.d/ubuntu.sources, improving readability and security metadata handling.
Step 2: Installing software-properties-common
The primary command-line tool for adding and managing PPAs on Ubuntu is add-apt-repository.
This utility is provided by the software-properties-common package, which is installed by default on desktop editions but may be omitted on minimal cloud server images.
Update your local package index and verify that the package is installed:
# Update repository cache:
sudo apt update
# Install software-properties-common:
sudo apt install -y software-properties-common
# Verify add-apt-repository availability:
add-apt-repository --help
Step 3: Adding a Personal Package Archive (PPA)
PPAs allow individual developers and teams to distribute software builds directly to Ubuntu users through Launchpad.
When you add a PPA using add-apt-repository, the utility automatically queries Launchpad, downloads the publisher's public GPG signing key, adds the repository URL to your APT configuration, and updates your package cache.
For example, to install the latest Git release directly from the official Git maintenance team's PPA, run:
# Add the Git team stable PPA:
sudo add-apt-repository -y ppa:git-core/ppa
# Notice on Ubuntu 20.04 and newer, APT cache updates automatically.
# Install or upgrade Git from the newly added repository:
sudo apt install -y git
# Verify installed Git version:
git --version
# Output confirms latest upstream release from PPA.
Step 4: Adding Third-Party Repositories with Modern signed-by Keyrings
Historically, third-party software vendors instructed users to run apt-key add to import repository signing keys.
However, apt-key has been completely deprecated because keys added globally via apt-key were trusted to sign packages from any repository on the system, creating a significant security risk.
The modern, secure standard requires storing public GPG keys in isolated files under /etc/apt/keyrings/ and explicitly scoping the key to its specific repository using the signed-by directive.
Here is the standard workflow demonstrated using the official NodeSource Node.js repository:
# 1. Install prerequisites:
sudo apt update && sudo apt install -y ca-certificates curl gnupg
# 2. Create dedicated keyrings directory with secure permissions:
sudo install -m 0755 -d /etc/apt/keyrings
# 3. Download and dearmor vendor public GPG key into keyrings:
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | \
sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
sudo chmod a+r /etc/apt/keyrings/nodesource.gpg
# 4. Add the repository source file with explicit signed-by scoping:
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | \
sudo tee /etc/apt/sources.list.d/nodesource.list > /dev/null
# 5. Refresh package list:
sudo apt update
Step 5: Understanding Ubuntu 24.04 DEB822 Format (.sources)
Starting with Ubuntu 24.04 LTS, Ubuntu transitioned its primary repository definitions to the multi-line DEB822 standard format.
Instead of a single long line beginning with deb http://..., DEB822 files use stanza blocks with explicit field names.
You can create custom third-party repositories using DEB822 format in /etc/apt/sources.list.d/example.sources:
Here is an example structure illustrating how a repository is represented in DEB822 format:
# /etc/apt/sources.list.d/example.sources
Types: deb
URIs: https://download.example.com/linux/ubuntu
Suites: noble
Components: stable
Architectures: amd64 arm64
Signed-By: /etc/apt/keyrings/example.gpg
Step 6: Removing and Disabling Repositories and Keys
If a repository becomes deprecated, abandoned, or unnecessary, remove it to prevent connection timeouts and security vulnerabilities during apt update.
To remove a PPA, pass the --remove flag to add-apt-repository:
To remove a third-party repository installed via keyrings, delete the configuration file from /etc/apt/sources.list.d/ and remove its corresponding GPG key from /etc/apt/keyrings/:
# Remove a Launchpad PPA:
sudo add-apt-repository --remove -y ppa:git-core/ppa
# Remove custom third-party repository and keyring:
sudo rm -f /etc/apt/sources.list.d/nodesource.list
sudo rm -f /etc/apt/keyrings/nodesource.gpg
# Refresh package cache:
sudo apt update
Troubleshooting and Common Errors
When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:
W: GPG error: ... The following signatures couldn't be verified because the public key is not available: NO_PUBKEY [KEY_ID]
Cause: The repository signing key is missing, expired, or improperly imported into APT.
Resolution: Download the missing public key using gpg --keyserver or vendor instructions into /etc/apt/keyrings/.
sudo gpg --keyserver keyserver.ubuntu.com --recv-keys [KEY_ID]
E: Conflicting distribution: ... 404 Not Found
Cause: The added repository does not offer pre-compiled packages for your Ubuntu release codename (e.g. noble or jammy).
Resolution: Check vendor documentation for supported Ubuntu versions or remove the repository source file.
cat /etc/os-release | grep VERSION_CODENAME
add-apt-repository: command not found
Cause: The software-properties-common package is not installed on your minimal system.
Resolution: Install the utility using sudo apt update && sudo apt install -y software-properties-common.
sudo apt install -y software-properties-common
Security Best Practices and Hardening
Never add untrusted personal repositories or execute random curl-to-bash installation scripts from unverified websites.
Avoid using deprecated apt-key add commands; always store third-party keys in /etc/apt/keyrings/ with the signed-by attribute.
Verify repository integrity by checking fingerprint signatures against the vendor's official published security advisory.
Related Ubuntu Tutorials and Documentation
Deepen your Linux system administration skills with our related production-tested guides:
- How to Fix the NO_PUBKEY GPG Error on apt update in Ubuntu — Diagnose and resolve missing APT repository cryptographic keys.
apt update vs apt upgrade vs apt full-upgrade— Master Debian and Ubuntu package cache updates and system upgrades.- Initial Server Setup on Ubuntu 24.04 LTS — Foundational baseline setup for Ubuntu cloud servers.
Authoritative References and Official Documentation

The Linux Command Line, 2nd Edition: A Complete Introduction
Frequently Asked Questions
Quick answers to common questions and configurations
apt-key added keys globally into a shared keyring (/etc/apt/trusted.gpg). This allowed any imported key to authenticate packages from any configured repository. The modern signed-by standard confines each key to its specific repository./etc/apt/sources.list.d/ as .list or .sources files.add-apt-repository automatically triggers an internal apt update after adding or removing a repository.Editorial Disclosure: Website Vidya is supported by our readers. When you purchase hosting, tools, or software through our verified partner links, we may earn an affiliate commission at no extra cost to you. We only recommend solutions we trust and rigorously verify.
Rajesh Ray
I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.
Most Read Guides
TrendingUbuntu Server Not Booting? 10 Simple Steps to Fix It Fast
How to Create a 3D Button in HTML and CSS: Easy Steps
How to Install Python and Pip on Ubuntu 24.04 LTS
How to Install Nginx on Ubuntu 24.04
How to Install Python on Ubuntu 24.04 LTS
Related Technical Guides
Tested runbooks, server administration walkthroughs, and troubleshooting guides
Join the Conversation & Perspective
Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.
No comments on this guide yet. Be the first to share your thoughts or ask a question!