How to undo sudo add-apt-repository?

From Ubuntu's manual pages (man add-apt-repository):

-r, --remove Remove the specified repository

So...

sudo add-apt-repository -r ppa:noobslab/indicators

This removes it from the repo list in /etc/apt/sources.list.d/.

Depending on what you are doing, BEFORE you run the above command - If an installed package from that repo is newer than the same package in a standard repo, then manually downgrade with ppa-purge:

sudo ppa-purge ppa:noobslab/indicators

For Debian, just delete the .list file in /etc/apt/sources.list.d/


add-apt-repository creates a new file in /etc/apt/sources.list.d for ppa repositories. Besides deleting the appropriate file you also should delete the added gpg key:

  1. get the keyid from apt-key list
  2. delete it via apt-key del $ID

If you want to undo add-apt-repository, having used a format like e.g.

sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

Use the output displayed by the following command to find the repository you want to delete

grep ^ /etc/apt/sources.list /etc/apt/sources.list.d/*

Example output:

/etc/apt/sources.list:#deb cdrom:[Linux Mint 17.3 _Rosa_ - Release amd64 20151128]/ trusty contrib main non-free /etc/apt/sources.list.d/additional-repositories.list:deb [arch=amd64] https://download.docker.com/linux/ubuntu trusty stable ...

In this example /etc/apt/sources.list.d/additional-repositories.list would have the repository to undo/remove. Edit the file and remove its line.