remove repository from ubuntu

How to Remove Repository in Ubuntu

Ubuntu software packages are installed from their software repositories. Sometimes you may need to delete a software repository in Ubuntu/Debian because it is no longer maintained or needed. In this article, we will learn how to remove repository in Ubuntu.

A software repository (also known as repo) is a centralized location for all software packages. Users can easily download, install and upgrade software packages on their system using package managers such as apt that automatically connect to these repositories to download software or updates. Ubuntu provides 4 software repositories – main, universe, restricted, multiverse. Apart from this, developers also maintain third-party repos to support software not available in official repositories.

Each repo also has a repository key (also known as GPG key) for data encryption and security. When you add new repository to your system, you need to add its key to your system, if you want the apt package manager to be able to trust and securely download packages from the repository.

How to Remove Repository in Ubuntu

Here are the steps to remove repository from Ubuntu.

Delete Repository in Ubuntu

If you are new to Ubuntu repositories, you should know that Ubuntu only stores the links to each repository, and not the actual contents of the repository.

When a repository is added using add-apt-repository command, the repository’s link is added to /etc/apt/sources.list file.

So to delete the repository, open the above file in a text editor.

$ sudo vi /etc/apt/sources.list

And look for the line pertaining to the repository and delete it. Here’s what link to Virtualbox repository looks like.

deb bionic contrib

Delete the line, save and close the file.

If you have added PPA repository, look into /etc/apt/sources.list.d/ folder and delete the repository’s entry.

Alternatively, you can also run the following command to delete repository. Replace nemh/systemback with the name of your repository.

$ sudo add-apt-repository -r ppa:nemh/systemback

Run the following command to update apt package manager on your system.

$ sudo apt update

Delete Repository Keys in Ubuntu

As mentioned earlier, each repository has a key. You can view the list of all keys using the following command.

$ sudo apt-key list

Each key is a 40 character alphanumeric string as shown below.

5820 13C2 C8B7 B4AB 713E 915B 24E4 9429 53C6 2A1B

To delete a specific key, just use the following command.

$ sudo apt-key del "5820 13C2 C8B7 B4AB 713E 915B 24E4 9429 53C6 2A1B"

Alternatively, you can also delete a key by mentioning its last 8 characters.

$ sudo apt-key del 53C62A1B

Run the following command to update the apt package manager.

In this article, we have learnt how to delete repository and its GPG key.

In most cases, you don’t need to remove or delete repositories from your system. But if you find that certain repositories have become old and are no longer maintained by Ubuntu, then it might be a good idea to remove the repository from your system. If you are using third-party repositories then too you can remove them if you don’t need them anymore.

Also read:

How to Deny SSH Access to Users or Groups
How to Batch Convert PNG to JPG in Linux
How to Convert Webp to Gif in Linux
How to Convert Images to Webp in Linux
How to Convert Images to Webp in Python

Leave a Reply

Your email address will not be published. Required fields are marked *