ubuntu delete software repository

Article directory

      • Method 1. Use apt to delete the warehouse
      • Method 2. Use GUI to delete the software repository in Ubuntu?
      • Method 3. Delete the warehouse through the directory (for experts?)
      • Additional steps: Delete the GPG key after deleting the repository (for advanced users)
      • Be careful what you add and remove

You can add external repositories in Ubuntu to access packages that are not available in official repositories.

For example, if you install the Brave browser in Ubuntu, add its repository to your system. If you add a PPA, it will also be added as an external repository.

When you don’t need specific software, remove it. However, the external repository still exists. You can and should also remove it to keep your system in pristine condition.

Ubuntu makes it easy to delete software repositories. There are different ways to do this:

  • Use the apt-add-repository command to delete the repository
  • Deleting a repository using the GUI (for desktop users)
  • By modifying the file contents of the /etc/apt/sources.list file (for experts)

But before that, if you are new to this concept, I strongly recommend that you become familiar with the concept of package managers and repositories.

Method 1. Use apt to delete the warehouse

Did you know you can also use the apt command to delete a repository? Well, technically it’s not part of the core apt command, but it works in a similar way.

When working with external repositories, you can use the add-apt-repository or apt-add-repository command (both are the same command).

First, list the added repositories using the following command:

apt-add-repository --list

The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly

list enabled repositories in Ubuntu

Once completed, you can remove from the list using the apt-add-repository command with the -r flag as shown:

sudo apt-add-repository -r repo_name

For example, if I want to delete the yarn repository, I have to use the following command:

sudo add-apt-repository -r deb https://dl.yarnpkg.com/debian/ stable main

The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly

Remove repository using the apt-add-repository command in Ubuntu

Press Enter to confirm.

Next, update the repository using the following command:

sudo apt update

Now, if you list enabled repositories, you won’t find deleted repositories there:

apt-add-repository --list

The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly

confirm repository removal process by listing enabled repositories in Ubuntu

That’s it!

Method 2. Use GUI to delete the software repository in Ubuntu?

Deleting a repository you know nothing about is not recommended as it may restrict you from installing your favorite packages in the future, so make sure you know what you are doing.

As one of the most beginner-friendly distributions, you can use the GUI to delete repositories without using the terminal.

To do this, first open the “Software & updates” app from the system menu:

The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly

search for software and updates from the system menu

Now, click on the “Other Software” section and it will list the PPAs and external repositories in the system.

A checked ? in the list is enabled.

To delete a repository, you must follow Three simple steps:

  • Select the warehouse to be deleted
  • Click the “Remove” button
  • Finally, click the “Close” button

The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly

Disable repository from Ubuntu

After clicking the Close button, it will open a prompt asking you to update the information when making changes.

Just click the “Reload” button:

The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly

Click on reload to after removing repository from Ubuntu and save changes

Alternatively, you can update the repository from the command line for the changes to take effect:

sudo apt update

Method 3. Delete the warehouse through the directory (for experts?)

Previously, I explained how to delete a repository using tools (GUI and CLI). Here, you will modify the system directory responsible for managing the repository (/etc/apt/sources.list.d).

First, change the working directory to sources.list.d and list its contents:

cd /etc/apt/sources.list.d/ & amp; & ls

The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly

list contents of sources.list.d directory

Here you will find a list of all repositories.

If you look closely, a repository will have two files. One with the .list extension and the other with the .save extension.

You must delete files with the .list extension:

sudo rm Repo_name.list

For example, here I deleted the node repository using the following command:

sudo rm nodesource.list

The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly

remove repository by removing the repository directory in Ubuntu

For the changes to take effect, update the warehouse index using the following command:

sudo apt update

Want to learn more about sources.list? Read this article.

Additional steps: Delete the GPG key after deleting the repository (for advanced users)

If you wish to delete the GPG key after deleting the repository, follow these steps.

First, list existing GPG keys using the following command:

apt-key list

Now, the output may be confusing to some users.

Here are things to remember:

  • The GPG key name will be placed above the dotted line (----)
  • The public key is on the second line

For example, here’s the data for a Chrome GPG key:

The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly

list GPG keys in Ubuntu

To delete a GPG key, you can use the last two strings of the public key (without any spaces).

For example, here’s how I would use the last two strings of Chrome’s public key (D38B 4796) to remove its GPG key:

sudo apt-key del D38B4796

The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly

remove GPG key in Ubuntu

Likewise, you can use the entire public key. But this time, you have to include spaces between the two strings, like this:

sudo apt-key del "72EC F46A 56B4 AD39 C907 BBB7 1646 B01B 86E5 0310"

Be careful what you add and delete

Especially when you are a new Linux user, you will encounter a lot of interesting software that is added to and deleted from the repository.

While it’s good to experiment, you should always be careful with anything you add/remove to your system. There are some things you should keep in mind, such as:Does it contain newer packages? Is it a trusted or maintained repository?

Being cautious will keep your system safe from unnecessary repositories and packages.

I hope this guide helps you delete unwanted repositories!