How to correctly remove a PPA source? [duplicate]

I've added many PPAs using the add-apt-repository command. Is there a simple way to remove these PPAs? I've checked in /etc/apt/sources.list for the appropriate deb lines but they aren't there.

This is on a server system so a command line solution would be great!


Solution 1:

There are a number of options:

  1. Use the --remove flag, similar to how the PPA was added:

    sudo add-apt-repository --remove ppa:whatever/ppa
    
  2. You can also remove PPAs by deleting the .list files from /etc/apt/sources.list.d directory.

  3. As a safer alternative, you can install ppa-purge:

    sudo apt-get install ppa-purge
    

    And then remove the PPA, downgrading gracefully packages it provided to packages provided by official repositories:

    sudo ppa-purge ppa:whatever/ppa
    

    Note that this will uninstall packages provided by the PPA, but not those provided by the official repositories. If you want to remove them, you should tell it to apt:

    sudo apt-get purge package_name
    
  4. Last but not least, you can also disable or remove PPAs from the "Software Sources" section in Ubuntu Settings with a few clicks of your mouse (no terminal needed).

Solution 2:

Simply run apt-add-repository again with the --remove option to remove a PPA added via the command-line. For example:

sudo apt-add-repository --remove ppa:kernel-ppa/ppa

Then update with:

sudo apt-get update

Solution 3:

Alternately, as ppas are stored in /etc/apt/sources.list.d you can find the one you want to remove by entering:

ls /etc/apt/sources.list.d

Then when you have noted the name of that offending ppa (e.g. myppa.list), you can enter:

sudo rm -i /etc/apt/sources.list.d/myppa.list

Take care with rm (hence why I have used the interactive switch so you can confirm your actions. Then run sudo apt-get update afterwards.

This method merely removes the ppa .list file; it does not remove any other files or sort out any other problems caused by the ppa; for that you could use ppa-purge after you have got your update ability back (I know you mentioned this in your question, but I am adding this point for future readers): see here for more information on ppa-purge.

Also take into account that if you previously added the key of the repo as trusted you should remove it:

# list the trusted keys
sudo apt-key list
# remove the key
sudo apt-key del KEY_ID

Solution 4:

You can use the

sudo ppa-purge ppa:repository-name/subdirectory

command in a terminal.

You will first need to install ppa-purge to use this command. To do so, use sudo apt-get install ppa-purge or click this button:

Install via the software center
(source: hostmar.co)

Find out more about it here.

Solution 5:

The answers to this question will help you.

You can manage PPAs in System > Administration > Software Sources or by removing files in /etc/apt/sources.list.d/.

You can also use a package called ppa-purge.

And, as I commented on the question I linked to above,

There is a bug on Launchpad requesting a --remove argument for the add-apt-repository command. I've submitted a merge request to get the feature implemented, but it hasn't yet been accepted. Hopefully you'll have this feature soon though.