According to How can PPAs be removed? there are mainly 3 methods to get rid of a PPA:

  • Use the add-apt-repository command:

    sudo add-apt-repository --remove ppa:???/???
  • Manually remove the .list file:

    sudo rm /etc/apt/sources.list.d/????.list
  • Use additional tools like e.g. ppa-purge... (not topic of this question)

I am curious what the difference between the first and second option is, i.e. is there anything more that add-apt-repository --remove does, compared to just deleting the .list file?

One example I could think of would be GPG keys that were installed together with the PPA. Will add-apt-repository handle and remove them in contrast to just rm-ing the .list file?

Please note that neither removing GPG keys nor using ppa-purge is the topic of this question!

  • Sorry, didn't see your third point. This might help you: Difference between "ppa-purge" and "add-apt-repository -r"?. add-apt-repository should remove them as well. – Ron Sep 17 '15 at 15:18
  • No, this is another question. – Pilot6 Sep 17 '15 at 15:19
  • You can delete keys from /etc/apt/trusted.gpg.d/ – Pilot6 Sep 17 '15 at 15:20
  • possible duplicate of How can I remove gpg key that I added using apt-key add -? – Pilot6 Sep 17 '15 at 15:23
  • @Pilot6 No duplicate, because my main question is the difference between add-apt-repository and manually deleting the .list file. GPG keys were just an example that came into my mind what could be a difference. Editing now to make that more clear... - But let the link stay there, as it's at least related. – Byte Commander Sep 17 '15 at 15:54

Both commands remove the PPA, but there is one basic difference:

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

This command will only delete content of .list file. It will not remove the file itself.

sudo rm /etc/apt/sources.list.d/????.list

Once you run this command, it will completely remove the PPA file.

However, in my opinion, it's better to use :

sudo rm /etc/apt/sources.list.d/????.list*

I generally use the last command with the trailing asterisk (*), because whenever we add any repository it will create two files under /etc/apt/sources.list.d/. First one is the .list file and second one is a backup of that, having the extension .list.save.

same case with command sudo apt-key del ???? and sudo rm /etc/apt/trusted.gpg.d/file.gpg. whenever we add keys two file created under /etc/apt/trusted.gpg.d/ file.gpg and file.gpg~ when you run command

sudo apt-key del ????

one file file.gpg will be deleted and second one will remain file.gpg~ as it is . However, in my opinion, it's better to use :

sudo rm /etc/apt/trusted.gpg.d/file.gpg*
  • Why would you want delete harmless backups? – muru Sep 17 '15 at 18:45
  • @muru !! that is my opinion i generally do that when i no longer want to use that repository. its depends on requirement if someone think it may be useful to keep in system then they can keep that . lets suppose if i added 30 repo PPA then there 60 file will created. next time if i add or remove any repo then we have to put more effort to search any file and modify. or you think it may be usable in future then you can also comment repo entries inside the file or you can copy content of that file somewhere . anyway its depend on requirement. – pl_rock Sep 18 '15 at 2:08
  • Seriously? O.o You need time and effort to grep through 60 files? O.o – muru Sep 18 '15 at 2:09
  • no time , i forgot to change name of that file to memorable name then i spent time which file have which entry. like some file use name like webupd8. – pl_rock Sep 18 '15 at 2:12
  • also in version 13 , 14 and may be earlier ubuntu version there is bug that create problem if your gpg key more than 40 then you have to delete some key for adding new one. bugs.launchpad.net/ubuntu/+source/apt/+bug/1263540 – pl_rock Sep 24 '15 at 12:28

No, apt-add-repository will not handle the GPG keys, so if you want to remove the keys as well, use rm /etc/apt/sources.list.d/???.list and then the GPG Keys from /etc/apt/trusted.gpg.d/

  • The keys are not stored in these lists. – Pilot6 Sep 17 '15 at 15:18
  • I know that. @Pilot6 – David Sep 17 '15 at 15:20
  • And why do you post this? – Pilot6 Sep 17 '15 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.