wifi and ethernet keep disconnecting

It may just be an internal error.

sudo apt-get purge network-manager
sudo apt-get update
sudo apt-get autoremove
sudo apt-get upgrade
sudo apt-get install network-manager
sudo apt install ubuntu-desktop

Do that then reboot.


If you decide to use David's answer, the Settings shortcut might be missing. To fix that, I used cshubhamrao's answer to reinstall ubuntu-desktop.

sudo apt purge network-manager
sudo apt autoremove
sudo apt update
sudo apt full-upgrade
sudo apt install network-manager
sudo apt install ubuntu-desktop