0

So I just installed Debian 9.0.0 on my PC and now I can't download packages with the Synaptic packet manager as the sources.list file under /etc/apt/ has only the DVD set.

All other lines are commented out, with this text above the 2 lines I'd like to take back in:

# Line commented out by installer because it failed to verify:

This is probably due to the fact that I wasn't connected to the Internet while installing Debian using the DVD.

Also apparently the DVD isn't detected under Debian as under /media/ it only says cdrom and cdrom0 no matter if I insert the DVD or not with both being empty. -> Not sure if that is a separate issue?

I cannot edit the sources.list file by just opening it with the texteditor as it's write-protected.
I thought about installing leafpad from here: https://packages.debian.org/stretch/amd64/leafpad/download and I'm not sure if that would help.

To me it seems that the most straight-forward way would be to open the texteditor as root, comment out the DVD sources and take the 2 security.debian.org sources back in. However I'm not sure how to do that.

I tried sudo gedit which gets me this (I translated the part after Unable to init server:):

No protocol specified
Unable to init server: Connection failed:connection buildup denied

(gedit:1297): Gtk-WARNING **: cannot open display: :0

I would greatly appreciate any help.

  • What about opening a console and using su - to become root? If that fails, what about changing to a fully black screen with CTRL-ALT-F2 (get back to the graphical interface with CTRL-ALT-F7) and login as root and the root password. Failing that, better just reinstall, other procedures are too complex to explain in a comment. – Arrow Jun 23 '17 at 1:22
  • @Arrow “better just reinstall, other procedures are too complex to explain in a comment” — so write an answer then... Note that on current Debian, the GUI is typically on VT2 so Ctrl-Alt-F2 isn’t going to do much. – Stephen Kitt Jun 23 '17 at 4:33
  • About writing an answer: there is no point as the user has moved to other questions, as you suggested. – Arrow Jun 23 '17 at 4:47
  • 1
    because I am shooting in the dark here not knowing the answer to all the above. That is not a problem but we need to work one step at the time. First, you said that su - worked, then, in that console whoami should say root, or id should report you are root. If so, edit any file with nano, like nano /etc/apt/sources.list. Second question, in a nrmal console (not root) could you execute sudo ls. If not, you need to edit sudoers. Then, after sudoers is correct, could you start a gui command like sudo xterm ?. If not we need to make xauthority of the running user available (cont.) – Arrow Jun 23 '17 at 10:58
  • 1
    @mYnDstrEAm You could start xterm (as root?). So, you do have a password for root and you have edited sudo to accept your user. Fine, anything else we should take a look to to repair here? – Arrow Jun 23 '17 at 19:07
1

Since you have sudo working, you should use sudoedit:

SUDO_EDITOR="gedit -w" sudoedit /etc/apt/sources.list
  • That only works as 2 separate commands. sudoedit /etc/apt/sources.list almost worked - I tried to save it with ctrl+o (it confusingly only said ^O) but then it asks me for the filename with only strange options instead of an option to replace the original file. How can I replace it? Furthermore I can't open the root console anymore - the screen only flickers black after I enter the password. – mYnDstrEAm Jun 22 '17 at 15:32
  • Let us continue this discussion in chat. – Arrow Jun 23 '17 at 4:50
  • Seriously, it’s a single command. If you want to make it two, first you need to export SUDO_EDITOR="gedit -w", then sudoedit /etc/apt/sources.list. – Stephen Kitt Jun 23 '17 at 20:31
1

You can use sudo to edit the file using a simple text editor such as nano or kate

sudo kate /etc/apt/sources.list

or if that doesn't work: sudo nano /etc/apt/sources.list

You should be able to then uncomment what you need and save.
This link will help with default lists: https://wiki.debian.org/SourcesList

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.