16

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!

Byte Commander
  • 107,489

2 Answers2

27

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*
muru
  • 197,895
  • 55
  • 485
  • 740
pl_rock
  • 11,297
  • 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 02:08
  • Seriously? O.o You need time and effort to grep through 60 files? O.o – muru Sep 18 '15 at 02: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 02: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. https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1263540 – pl_rock Sep 24 '15 at 12:28
  • ... which doesn't say anything about backup files. – muru Sep 24 '15 at 12:30
  • In 14.04 and beyond it's worth looking in /var/lib/apt/lists for PPA files – Elder Geek May 06 '17 at 20:05
1

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/

David
  • 3,367