I accidentally added a repository with sudo add-apt-repository "deb http://archive.canonical.com/ $(lsb_release -sc) partner" and since then I am getting an error whenever I try the sudo apt update command. I am pretty sure its because of the above repository. I searched on google and found out that the repository can be removed by manually visiting the /etc/apt/sources.list.d/ folder but the above repository is not present there. I have also tried the ppa-purge but was unable to remove the repository. How do I remove the above repository?

screenshot of "sudo apt update"

screenshot of /etc/apt/sources.list.d/

  • 2
    Please don't post images of text. Copy and paste the text itself into your question and format it as code by selecting it and pressing Ctrl-K or by using the editor's {} icon. and don't post GUI directory listings, either - post the text output of ls -l.
    – cas
    Sep 16 '19 at 4:01

According to the man page you can use the same command with the -r option to remove the repository:

sudo add-apt-repository -r "deb http://archive.canonical.com/ $(lsb_release -sc) partner"

I didn't fully understand in which case a new repository file is added to the /etc/apt/sources.list.d directory, but if it's not there, then it must have been added to your /etc/apt/sources.list and you can also remove it manually from there.


The man page (man add-apt-repository) says that it manages repositories not only under the directory /etc/apt/sources.list.d/ but also in the file /etc/apt/sources.list.

If you can't find a reference to your unwanted repository under /etc/apt/sources.list.d you should also check the file /etc/apt/sources.list.

As mentioned already the documentation also describes the -r (--remove-) flag to remove an existing repository.

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.