47

I tried to upgrade Ubuntu from Hardy to Intrepid last night, however I seem to have killed it.

I can boot into "recovery mode" and access the root shell, however it freezes when I try to start the GNOME environment, etc.

In recovery mode, it doesn't appear to be connected to the internet (ie. ifconfig shows the lo bit but not the eth0 bit), and I can't ping it or access it via SSH.

How can I start networking from this prompt?

1

6 Answers 6

35

Do you normally get your IP address from DHCP server ?

$ ifconfig eth0 up 
$ sudo dhclient eth0

To set IP address you want (for example 192.168.0.1) type:

ifconfig eth0 192.168.0.1 netmask 255.255.255.0 up
route add default gw GATEWAY-IP eth0

If you have a problem with gdm during the boot, switch to the real console:

Use the Ctrl-Alt-F1 shortcut keys to switch to the first console.

To switch back to Desktop mode (gdm), use the Ctrl-Alt-F7 shortcut keys.

5
  • 2
    Don't forget to add your default gateway (if you want internet access): route add default gw <gateway-ip> Commented Jun 7, 2009 at 15:31
  • +1 Still works on 12.04. PS: you don't need sudo in recovery mode.
    – l0b0
    Commented Feb 1, 2013 at 20:16
  • Formatting @MattSimmons ' comment for n00bs like me: route add default gw <gateway-ip> Commented Aug 26, 2019 at 0:23
  • just adapter-name, to be specific to your environment. e.g. eth0, would be enp0s3 (default) in my case, when running on virtual machine. (+1)
    – parasrish
    Commented Mar 11, 2020 at 3:54
  • can you be clear about more situations? Is this wifi, direct? What? No idea.
    – safetyduck
    Commented Nov 3, 2023 at 13:08
17

Step by step with ip

  1. Get the name of the network interface with the ip link command. The name may differ with motherboards. It should be different from lo, the virtual local interface.
# ip link
  1. Assuming the network interface is called eth0, the following command will bring the interface up. This should now be visible when executing the command ip link once more.
# ip link set eth0 up
# ip link
  1. Next, a local IP address needs to be obtained from the router. The second command is again for checking.
# dhclient eth0
# ip addr show dev eth0
  1. Finally, a temporary domain name server (DNS) is required to translate URLs to IP addresses. This can be either the router in the LAN (if previously/automatically properly configured), the DNS of the ISP or —if you still trust them— Google's DNS at 8.8.8.8 This requires editing a system configuration file that normally should not be edited. However, any changes made will automatically disappear when rebooting.
# nano /etc/resolv.conf

Add a line containing, for example:

nameserver 192.168.178.1

Some more helpful commands

Personally, I ended up in this dire situation by replacing an NVidia video card with a much older model. Once the networking established, the following set of commands allowed me to successfully install the proper NVidia card driver.

# update-drivers autoinstall
# update-initramfs -k all -u
# update-grub
1
  • 2
    This is much more useful than the accepted answer if you have newer version of Ubuntu that doesn't come with net-tools for ifconfig. +1
    – GPPK
    Commented Aug 7, 2021 at 11:00
7

To start networking, /etc/init.d/networking start should do the trick. I'd say that if Gnome isn't starting, you've got X config problems. If you disable gdm from starting on boot, then you should be able to get to a regular console prompt and do diagnosis from there (check /var/log/Xorg.0.log and so on).

7

In newer versions of Ubuntu name resolution does not work via /etc/resolv.conf anymore. Thus you need to do something like

dhclient eno1
systemctl start systemd-resolved
3
  • this is what worked for me on ubuntu 18.04
    – brad
    Commented Jun 11, 2020 at 14:45
  • worked for me, ubuntu 20.04
    – Tekno
    Commented Jan 31, 2021 at 11:35
  • This fixed my networking issue from terminal on ubuntu 22.04 LTS ..
    – Gautam
    Commented Sep 3, 2023 at 5:44
3

You can go back to the recovery menu options by login-out (cntrl + D), then select the option "Network ------- Enable networking" and Ubuntu will do the rest for you to activate networking. You will be brought back to this menu screen, so you can get back to the shell prompt and continue whatever you were trying to fix.

0

Just start the network manager in recovery mode

systemctl start network-manager

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .