APT – Remove PPAs: add-apt-repository –remove vs. rm /etc/apt/sources.list.d/*.list

add-apt-repositoryaptpackage-managementpparepository

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!

Best Answer

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*
Related Question