0

My laptop recently couldn't enter GUI mode and could only enter CLI mode. I've looked for a solution on the internet but most people suggest doing:

sudo apt-get --reinstall ubuntu-desktop

Unfortunately, I accidentally deleted the network-manager so now my laptop can't connect to the internet.

How to return Ubuntu to GUI mode after deleting network-manager?

  • 1
    That should be sudo apt install --reinstal ubuntu-desktop or sudo apt reinstal ubuntu-desktop... and you can do it from a live system (internet enabled) see for example https://askubuntu.com/a/1485452 – Raffa Dec 06 '23 at 14:24
  • 1
    Easiest way to recover is to boot Ubuntu from a live USB, take a backup of important files (if any) in your home folder, and reinstall Ubuntu – Archisman Panigrahi Dec 06 '23 at 14:58
  • "unfortunately I accidentally deleted network-manager" That is an impressive 'accident'. A stock install of Ubuntu has several layers of protections against such events...suggesting that you disabled or ignored them. Try to avoid that next time, and you will find Ubuntu much less frustrating. – user535733 Dec 06 '23 at 15:53
  • @user535733 a Ubuntu without NetworkManager, now that would be less frustrating *for me at least I know people find Network Manager easier then maning the ifupdown scripts/systemd scripts – Luke Attard Dec 07 '23 at 09:40

1 Answers1

0

I am assuming you are using the LTS 22.04 version of Ubuntu.

Network Manager is not required to connect to the internet. Assuming you have a DHCP server on your network, and you have the phyiscal connection/Wifi connected. Then in a shell as root or using sudo run:

ip -br a                     ##I find using -br is easier to read, specially if you have a lot of interfaces 

Identify the name of the interface you using, eg eno1, enps0f3, eth0. Also confirm the interface is up. If it is up, skip to the next dot point, if it is not run:

ip link set <int name> up 

If the interface was down, and you have bought it up, check if it has an ip address now. Often the interface will be setup to request an IP from the dhcp server when it is bought up.

  • Check connectivity

If you have an IP address it now has an ip address, and is up, try and "ping 8.8.8.8" if you can, then you now have internet, almost, maybe.

The internet uses DNS to link domain names to IP addresses, to check if DNS is setup correctly, ping google.com (or any domain you know). If the address is converted to an IP, then your are good to go. Now you can reinstall NetworkManager (if you want) and Ubuntu Desktop.

  • Fixing DNS

To fix dns, we first want to check the current status of resolv.conf. run:

ls -la /etc/resolv.conf

resolv.conf may be a ASCII file, or a symbolic link to another file. eg: ../run/resolvconf/resolv.conf or /run/systemd/resolve/stub-resolv.conf

If it is a link to another file, confirm that file exists. having a broken link is a common problem that can break dns. If the link is broken, you can either create the file where the link points to, or remove the link, and recreate the resolv.conf file (see below for how ot recreate the file)

If the link is correct, or /etc/resolv.conf is a file. run cat:

cat /etc/resolv.conf 

THe output will be something like:

nameserver 127.0.0.53
options edns0 trust-ad
search somelocal.domain

or

nameserver 10.10.10.10
search somelocal.domain

If you have 127.0.0.53 or another 127.x.x.x address then your system is using a local service that proxies your dns requests. As you are wanting to install NetworkManager, that will take over dns once fixed, the quickest fix is to tempory override the settings, and let NetworkManager do its black magic to the dns.

  • Create / Update server resolv.conf is using.

The quickest way to fix dns is by overriding the file/creating resolv.conf by running:

echo nameserver 8.8.8.8 > /etc/resolv.conf      **or the location the symbolic link points to, if you had a broken link.

this command sets your system to use the google name server that we confirmed in step one, we could reach this should get you online, and then you can install fix what you need.

  • Fixing the GUI without reinstalling - maybe

When Ubuntu boots, it will either load the graphical interface by using a display manager, there is a few of them out there, use the one you like. xfwm, part of xfce4 is my prefered.

to confirm what is the current setting run:

systemctl get-default

if the output is graphical.target, then your system is setup to load the GUI, normally on tty7. If it shows multi-user.target, then you are set to boot to console, normally tty1.

to change run

systemctl set-default graphical.target    ** or multi-user.target if that is your prefered. 

This may fix the issue that you are haivng with the GUI. Also note, you can often start the GUI, unles sit is broken, by running startx on the console, or via a ssh client that has been setup either with ssh-X-Forwarding or a remote X11 server. Once your GUI has loaded, you may be able to the fix the problem you have within the GUI.