On Linux a set of packages are installed by default. But the default packages are never enough. You may want to set up a file server, or a web server, or a database server or something else. For that you need to install additional packages. We use a package manager like apt to install and manage packages on Linux. The package manager downloads and installs packages from a package repository. A package repository is a HTTP or FTP server on the web where a set of packages are kept on the internet along with the package metadata that a package manager like apt downloads and uses first to find out what packages are available on the package repository.
In this tutorial, we will show you two ways to add apt repository on Ubuntu and Debian systems. The first method is by using the
add-apt-repository command and the second one is to manually add the repository using a text editor.
Using add-apt-repository command
add-apt-repository (or symlink
apt-add-repository) command to add launchpad PPA to your system. You just need to provide launchpad reference address as the following command.
# sudo add-apt-repository ppa:libreoffice/ppa
[box type=”note” align=”” class=”” width=””]You can fixed error add-apt-repository command not found if occurred.[/box]
For other hosted repositories, can be also configured by providing its reference as below:
sudo add-apt-repository 'deb http://repo.tld/ubuntu distro component'
Create Files Manually
You can just create a file in
/etc/apt/sources.list.d directory. The file name must end with .list extension. The apt package manager also read repository configuration files from here.
# sudo nano /etc/apt/sources.list
You should see the following window as shown in the screenshot below.
Add the repository paths as below.
deb http://archive.getdeb.net/ubuntu wily-getdeb games
You can add multiple repository references in a single file as required.
Before installing the packages from the newly added repository you must update the package index:
# sudo apt update
Once the package index is updated you can install packages from the newly added repository.
We have shown you how to add apt repositories in Ubuntu. The same instructions apply any Debian based distribution, including Kubuntu, Linux Mint and Elementary OS.
Feel free to leave a comment if you have any questions.