Ubuntu: sources list editing [Guide]
If you need to edit the software sources list on your Ubuntu PC to add a repo, disable an existing repo, or remove a repo altogether but don’t quite understand how to do it, we can help! Follow along to learn all about Ubuntu sources list editing!
Ubuntu: sources list editing – Software & Updates app
The Software & Updates application that is included with Ubuntu is by far the best way to edit your Ubuntu sources list. The reason? It’s a simple tool that isn’t overly complex, and everything is done within a few steps, rather than the drawn-out process that can occur in the terminal or even with a GUI text editor.
To start editing your sources list on Ubuntu with “Software & Updates,” launch the app by searching for “Software & Updates” in the app menu. Once the program is open, follow along below.
Adding new repos
If you want to add a new repo to Ubuntu by editing your sources list, here’s how to do it with the Software & Updates app. First, find the “Other Software” tab in the app window and click on it with your mouse.
After accessing the “Other Software” tab, you’ll see a list of software sources enabled on Ubuntu. Keep in mind, “Other Software” is only for non-Ubuntu repositories. Think PPAs or other third-party software repositories.
To add a new repository to your sources list, find the “Add” button at the bottom-left corner of the screen, and click on it with the mouse. When you’ve clicked on it, you will see a window appear.
In the window that appears on the screen, you will be asked to add the repo line. Paste it in the text box and press “Add Source.” After selecting the “Add Source” button, you will be asked to enter your password. Do so.
Once your password has been entered into the text box, your new software source will be added to Ubuntu via “Software & Updates.”
Disabling repos
The “Software & Updates” app also allows Ubuntu users to quickly and easily disable repos in the Ubuntu software sources list. To do it, ensure you have “Software & Updates” open. You can open it by searching for it in the app menu.
Once the app is open, find the “Other Software” tab, and click on it with the mouse. By selecting the “Other Software” tab, you will be able to access the Ubuntu sources list.
To disable or “turn off” a repo temporarily (AKA not delete it forever,) uncheck the box next to it. After unchecking the box, click on the “Close” button. When you click “Close,” the Software & Updates app will ask to reload. Click the “Reload” button to apply changes.
Removing repos
The Software & Updates app is excellent for removing repos from the Ubuntu sources list. Here’s how to do it. First, launch the “Software & Updates” app via the app menu. Once it is open, click on the “Other Software” tab to access the other software area.
Inside of the “Other Software” area, look for the repo you wish to remove from the Ubuntu sources list. Then, click on it with the mouse. Select the “Remove” button to delete it from your Ubuntu sources list.
When done editing, click on the “Close” button. Upon clicking “Close,” the app will ask you to reload. Click on the “Reload” button to apply changes.
Ubuntu: sources list editing – Terminal
Editing the Ubuntu sources list in the terminal means opening up the /etc/apt/sources.list
file in a text-based editor like Nano and manually entering or removing text to disable or enable software repositories.
Adding new repos
There are many ways to add new repos to your Ubuntu sources list file. The best way to do it, however, is with the add-apt-repository command. The reason? It’s swift and efficient.
To add a new repo to your Ubuntu sources, execute the command below. Keep in mind that you will also need to provide the GPG key for the repo.
sudo add-apt-repository "deb http://your-new-repository-here.com ubuntu-release main"
After adding the repo, just run the sudo apt update command and follow the software vendor’s instructions to add their repo’s GPG signing key.
Alternatively, open up the Ubuntu sources file in the Nano text editor.
sudo nano -w /etc/apt/sources.list
Once in Nano, move to the very bottom of the file and paste your new repo. Then, save with Ctrl + O, exit with Ctrl + X, and run:
sudo apt update
Disabling repos
To disable a repo, you will need to shut them off from the sources file manually. To do that, open it up for editing with the following command.
sudo nano -w /etc/apt/sources.list
Inside the Nano editor, locate the software repository you wish to remove. Once you’ve found it, place a # symbol directly in front of it. Doing this will shut off the repo.
Save the changes with Ctrl + O, exit with Ctrl + X, and update with update.
sudo apt update
Once the update command has run, the repo will be shut off from the system.
Removing repos
Need to remove a repo altogether? The only way to do this in the terminal is by erasing the repo line from the sources file using a text editor like Nano.
To start, open up your sources file with the Nano text editor by using the command below.
sudo nano -w /etc/apt/sources.list
Once inside of the Nano text editor, scroll through, find the repo to delete, and use the Delete key to remove it. Then, save with Ctrl + O, exit with Ctrl + X, and update the changes to Ubuntu with update.
sudo apt update