While installing python-pip I accidentally edited sources.list file and it's corrupted my entire pc. Please help me! I want to factory reset Ubuntu but nothing on the internet is helping me here. All the terminal commands related to apt are returning an error that "cdrom/d " (the line I edited) is not known in sources.list Can someone please please help me out here. Never used Ubuntu in my life and my first experience was this -_-

  • Ubuntu does not have a "factory reset". The equivalent is a reinstall. Why don't you just change the line back? – user535733 Nov 3 '17 at 17:22
  • 1
    What is the output of cat /etc/apt/sources.list and the output of same command used on the files in /etc/apt/sources.list.d? you can edit your question to include that information. – Videonauth Nov 3 '17 at 18:00

1.sudo nano /etc/apt/sources.list

2.Put a # at the beginning of the cdrom line you edited/added.

3.Ctrl+o to save, Ctrl+x to exit nano.

4.sudo apt-get update

If that works and you get no errors, you can try

5.sudo apt-cdrom add to get the cdrom entry added properly.


You can reinstall the entire OS, that'll get your file back. That's a big thing to do though.

You could also use a 3rd party service like SimplyLinux's RepoGen, but that's a 3rd party tool, so your mileage may vary here.

If that scares you, you could always try $ sudo apt edit-sources and comment out the offending line(s) in your sources file.

A third option (a risky one!) would be to reinstall apt:

$ sudo apt-get --reinstall install apt

Hope this helps!

  • Please delete the last suggestion. It will not work if the OP has a broken sources.list and it wont be necessary if his sources.list is not broken. Your second suggestion is actually the best, as reinstalling the OS only because of a corrupted sources.list file is way overkill. – Bruni Nov 3 '17 at 17:55
  • You mean the apt edit-sources suggestion, or the reinstalling of apt itself? I'm confused which one you mean, since my last suggestion is reinstalling apt, which also copies the default configs into place, which would solve his issue I think – Sebastiaan Franken Nov 3 '17 at 20:24
  • reinstalling apt is the one I would delete. Reinstalling apt by using apt will be impossible if the sources.list file is corrupt. – Bruni Nov 4 '17 at 7:07
  • Thanks, but it was not needed. I just commented the line. What I didn't know is that you can edit it with gedit externally. The first time I edited it it opened inside the terminal itself. I'm sorry being such a noob. – Sarvesh Patil Nov 4 '17 at 17:28

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.