Remove PPAs: "add-apt-repository --remove" vs. "rm /etc/apt/sources.list.d/???.list"

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*

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/