- Published on
linux add-apt-repository: Add a new apt repository
Jonas
Adding a new apt repository in Linux using the add-apt-repository
command is a simple way to expand your software sources and access additional packages. This command is specifically designed for Debian-based distributions, such as Ubuntu.
To add a new apt repository, simply follow these steps:
-
Open a terminal by pressing
Ctrl + Alt + T
. -
Type the following command to install the necessary utility, if it is not already installed:
sudo apt install software-properties-common
- Once the installation is complete, you can use the
add-apt-repository
command to add a repository. The basic syntax is as follows:
sudo add-apt-repository repository_url
Replace repository_url
with the URL of the repository you wish to add.
Note: Some repositories may require additional steps, such as importing a GPG key. Please refer to the repository's documentation for specific instructions.
For example, if you wanted to add the popular Wine repository, you would use the following command:
sudo add-apt-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ focal main'
After running the command, you will see output similar to the following:
Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
...
Hit:12 https://dl.winehq.org/wine-builds/ubuntu focal InRelease
Reading package lists... Done
Once the repository is added, you can proceed to update the package lists by executing the following command:
sudo apt update
Tips:
- Make sure you trust the repository you are adding, as it can potentially affect the stability and security of your system.
- Always ensure you are using the correct repository URL for your Linux distribution version.
- To remove a previously added repository, you can use the
remove-apt-repository
command. For example:
sudo remove-apt-repository repository_url
That's it! You can now explore and install packages from the newly added apt repository using the apt
or apt-get
commands. Happy exploring!