A key attribute of Linux is enabling you to create repositories if you want to access either official or third-party software in your system. But have you ever thought about how you get rid of those repositories once they meet your needs? On top of that, removing old repositories provide faster updation of the system without errors. So, in this article, I will show you several ways to remove apt repositories from your Linux system.
Key Takeaways
- Removing Repositories Using CLI.
- Learning Repository Removal Manually from the Source apt Directory.
- Using GUI to Delete Repository.
Requirements
- Need to be a root user or have root/sudo privileges.
- Prior knowledge of command line interface.
Process Flow Chart
[Distro Used Throughout the Tutorial: Ubuntu 22.04]
2 Methods to Remove APT Repositories on Ubuntu
There are various ways to remove apt repositories in Ubuntu. Here, I have mentioned 2 effective methods (using CLI and GUI).
Method 01: Using CLI (Command Line Interface) to Remove APT Repositories
You can undo the addition of any repository from the command line. The process is very simple requiring only a few commands. Now, I will walk you through two different approaches with practical demonstration.
A. Utilizing apt-add-repository Command for Deleting Repository
You can delete a repository using a very straightforward command.
Steps to Follow >
➊ First, open your Ubuntu terminal. You can try, the shortcut: CTRL+ALT+T.
➋ Now, type the following command.
apt-add-repository --list
- apt-add-repository: It is used for adding or deleting a repository.
- –list: An option returning the list of current repositories available to the apt package manager.
➌ After that, press the ENTER button.You should see the list of current repositories on your system like the picture above.
Now, you can remove any repository you find not useful. For example, I will remove deb http://archive.getdeb.net/ubuntu wiley-getdeb games repository from my system. Now, to do the same for your intended repository, follow the below steps.
➍ Type the below-mentioned command.
sudo apt-add-repository --remove deb http://archive.getdeb.net/ubuntu wiley-getdeb games
- sudo: Prefix used to get sudo/root privileges.
- apt-add-repository: Main command for adding/deleting repository.
- –remove: Option telling the command to remove repository.
- deb http://archive.getdeb.net/ubuntu wiley-getdeb games: Repository url to be deleted.
➎ Now, hit ENTER.
At this point, you will be asked to give your user account password to access the sudo privilege like the following snapshot.➏ Type the password and hit the ENTER key.
➐ Now, type the command mentioned below:
sudo apt update
- sudo: Provides root privileges.
- apt: Tool for managing packages in the user’s system.
- update: Updates software packages.
➑ Now, provide your root password and press ENTER.
➒ Again, type the following command.
apt-add-repository --list
➓ Finally, hit the ENTER key.Here, you can spot that my system doesn’t contain the apt repository namely deb http://archive.getdeb.net/ubuntu wiley-getdeb games. This implies that I have successfully removed the repository.
B. Removing an APT Repository from the “Source APT Directory”
The system directory named (/etc/apt/sources.list.d/) handles the management of repositories. So, you can remove any unnecessary repository by simply modifying the sources.list file located in that directory since it is the principal apt source configuration file.
Steps to Follow >
➊ First, press CTRL+ALT+T to redirect to your Ubuntu terminal.
➋ Type the following command.
apt-add-repository --list
➌ Press ENTER.➍ Now, type the command mentioned below:
nano /etc/apt/sources.list
- nano: Command used to open and edit files in the nano text editor.
- /etc/apt/sources.list: File to be edited.
In the above image, you see the sources.list file is now open on the text editor where you can further notice the list of repositories.
➎ Now, remove the entire line of the repository name you want to remove by pressing the BACKSPACE button. For instance, I will remove the repository named deb http://archive.getdeb.net/ubuntu wiley-getdeb games.➏ After that, press CTRL+S to save and then CTRL+X to exit the file.
➐ Again, type the following command.
apt-add-repository --list
➑ Finally, press the ENTER button to see the updated list of repositories.In the image, I have fetched the repositories and you see the wiley-getdeb games repository has been removed.
Method 02: Using GUI (Graphical User Interface) to Remove APT Repositories
You may want to use the GUI(Graphical User Interface) to remove repositories. The process is very straightforward as follows:
Steps to Follow >
➊ First, go to your applications menu and type Software & Updates.➋ Now, click on the Software & Updates app and select the Other Software option.
➌ Click to select the repository you want to remove from your machine.
➍ Then, click on the Remove button and after that hit the Close button.➎At this point, click on the Reload button to update the repository information.
Finally, in the following snapshot, you can see that only the selected repository has been removed and the remaining ones are shown after updating.
Comparative Analysis of Methods
The following table gives an essence of the aforementioned methods as far as the apt repository deletion is concerned.
Methods | Pros | Cons |
---|---|---|
Method 1 |
|
|
Method 2 |
|
|
The picking of methods depends on several factors such as the beginner may find the visual representations of GUI(method 2) more perceivable. On the contrary, experienced users would advocate the use of command line and source file editing(method2) considering the level of performance and control appeal to them more. Every method works just fine. Henceforth, they are left to your personal choice.
Common Challenges That May Arise During Repository Configuration in Linux
Foremost, in the second method, I displayed removing apt repositories using GUI. It is the easiest method of the lot. However, an issue takes place while the execution.After pressing the Remove button, you get an alert saying Authentication Required like the aforementioned snapshot. Here, providing the user account password for authentication smoothly resolves the issue and removes the selected repository in consequence.
Secondly, in method 1(B), I exhibited removing an apt repository by modifying the sources.list file. But after accessing the file running nano /etc/apt/sources.list command, you might not be able to remove the repositories’ package reference url since you lack the write permission.In the above screenshot, it’s seen that I am denied writing permission when attempting to remove the package link deb http://repo.tld/ubuntu distro component.
Don’t let yourself get overwhelmed by the situation. Just alter the permission of the file named sources.list.
Steps to follow >
➊ First, open your Ubuntu Terminal.
➋ Now, type the following command
sudo chmod a+w /etc/apt/sources.list
- sudo: Prefix used to get sudo/root privileges.
- chmod: Command used to change permission.
- a+w: Grants write permission to all the users.
- /etc/apt/sources.list: The file which is modified for repository configuration.
➌ After that, type the following command to see the permission details
ls -l /etc/apt/sources.list
- ls -l: This command returns the detailed list of contents of the current working directory.
In the above image, you can see that all the users are granted permission to write the file. Finally, you are good to go.
Conclusion
In this feature, I have discussed the removal processes of repositories along with providing multiple pragmatic examples. Using these methods, you can easily remove the repository from your system that you no longer require. I hope that the hands-on experience will aid your learning of repository management and take you one step further in becoming a Linux power user.
People Also Ask
Related Articles
- The Universe Repository in Ubuntu [Enable, Install, Disable]
- The Repository Mirror in Ubuntu [An Extensive Overview]
- How to Add Repository in Ubuntu? [2 Simple Methods]
- How to Update Repository List in Ubuntu[3 Cases]
- [Solved] add-apt-repository Command Not Found Error in Ubuntu
- How to add an APT Repository Proxy in Ubuntu [Easiest Guide]
<< Go Back to Repository Configuration in Linux | Package Management in Linux | Learn Linux Basics