Note: This article was originally published in 2013. Some steps or software versions may have changed. Check the current Ubuntu documentation for the latest information.
In this guide, you’ll learn the basics of Ubuntu software repositories and how APT (Advanced Packaging Tool) manages packages. Ubuntu is a popular Linux distribution based on Debian, widely used for servers and development environments.
Prerequisites
Before you begin, make sure you have:
- A system running Ubuntu (desktop or server edition)
- Terminal access with sudo privileges
- Basic familiarity with Linux command line
Understanding APT and sources.list
Ubuntu uses APT for package management. APT stores a list of repositories (software channels) in the file /etc/apt/sources.list. This is important because if you want to add sources for software packages, you’ll either edit this file or add a referenced source file in the same format.
Backing Up Your sources.list
As with anything that deals with your system’s configuration, it’s recommended you perform a backup first:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
Typical sources.list Format
A typical sources.list file looks as follows:
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://archive.ubuntu.com/ubuntu/ jammy main
deb-src http://archive.ubuntu.com/ubuntu/ jammy main
Note: If you’re using a cloud instance, the file may be managed by cloud-init. In that case, add sources in
/etc/apt/sources.list.d/instead.
Adding a PPA Repository
If you want to add an additional repository, you can do it via the command line:
sudo add-apt-repository ppa:<repository-name>
This will create a new .list file under /etc/apt/sources.list.d/ where the entries are included as part of the sources.list. This approach allows for easier maintenance of multiple PPA sources.
After adding a repository, update your package list:
sudo apt update
Summary
You’ve learned the basics of Ubuntu software repositories, how APT manages packages through sources.list, and how to safely add PPA repositories. Understanding this system is fundamental for managing software on any Ubuntu system.