Remove PPAs: "add-apt-repository --remove" vs. "rm /etc/apt/sources.list.d/???.list"
Solution 1
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*
Solution 2
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/
Related videos on Youtube
Byte Commander
Ask Ubuntu moderator♦, IT student and DevOps engineer. I love Ubuntu, Python, good music and coffee, although not necessarily in that order. You can easily contact me in the Ask Ubuntu General Room most of the time, or on Discord as @ByteCommander#2800. I'd also love to invite you to my Ubuntu Hideout Discord Server btw. PS: My profile picture is derived from "Wolf Tribals" by user HaskDitex (DeviantArt.com), which is under creative Commons 3.0 License. Currently I'm using the character "Dregg Morriss" from the game "Medieval Cop" by Vasant Jahav ("Gemini Gamer"). It can be found here.
Updated on September 18, 2022Comments
-
Byte Commander 3 monthsAccording to How can PPAs be removed? there are mainly 3 methods to get rid of a PPA:
-
Use the
add-apt-repositorycommand:sudo add-apt-repository --remove ppa:???/??? -
Manually remove the
.listfile: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 --removedoes, compared to just deleting the.listfile?One example I could think of would be GPG keys that were installed together with the PPA. Will
add-apt-repositoryhandle and remove them in contrast to justrm-ing the.listfile?Please note that neither removing GPG keys nor using
ppa-purgeis the topic of this question!-
Ron about 7 yearsSorry, didn't see your third point. This might help you: Difference between "ppa-purge" and "add-apt-repository -r"?.add-apt-repositoryshould remove them as well. -
Pilot6 about 7 yearsNo, this is another question. -
Pilot6 about 7 yearsYou can delete keys from/etc/apt/trusted.gpg.d/ -
Pilot6 about 7 yearspossible duplicate of How can I remove gpg key that I added using apt-key add -? -
Byte Commander about 7 years@Pilot6 No duplicate, because my main question is the difference betweenadd-apt-repositoryand manually deleting the.listfile. 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.
-
-
Pilot6 about 7 yearsThe keys are not stored in these lists. -
David about 7 yearsI know that. @Pilot6 -
muru about 7 yearsWhy would you want delete harmless backups? -
pl_rock about 7 years@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. -
muru about 7 yearsSeriously? O.o You need time and effort to grep through 60 files? O.o -
pl_rock about 7 yearsno 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 about 7 yearsalso 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 -
muru about 7 years... which doesn't say anything about backup files. -
Elder Geek over 5 yearsIn 14.04 and beyond it's worth looking in/var/lib/apt/listsfor PPA files