3

I was following this guide on upgrading to Ubuntu 18.04, and after executing sudo apt-get dist-upgrade, I did not bother to check that it prompted me that executing it will remove lots of programs. After dist-upgrade, I noticed that I do not have sudo anymore. I tried installing via install but I get an error that looks like this:

E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

How can I recover from this?

akubi
  • 131
  • 3
  • So basically you are in the same situation as this --> [Can sudo be reinstalled after being removed?](https://askubuntu.com/questions/434525/can-sudo-be-reinstalled-after-being-removed) – steeldriver Jul 29 '19 at 00:57
  • 1
    @steeldriver I'm in a worse situation I think, ```pkexec``` is not installed and I have to install ```policykit-1```. Running ```apt-install policykit-1``` results in the error message I posted. – akubi Jul 29 '19 at 01:00
  • 1
    Probably safer to reinstall whole system, since you don't know what other programs are messed up. – Daniel Jul 29 '19 at 01:15
  • @Daniel that seems to be the only thing to do in this situation... – akubi Jul 29 '19 at 01:23
  • Had you enabled root login? By default it's disabled, but if you've enabled it, login as root so you don't have to use `sudo`. – guiverc Jul 29 '19 at 01:30
  • 3
    Related (but *not* a duplicate): [How to restore a system after accidentally removing all kernels?](https://askubuntu.com/q/28099) shows how to chroot from a live environment to use an installed system's package manager. [Andrea Corbellini's answer](https://askubuntu.com/a/249373) to [Ubuntu system is broken after accidentally uninstalling many packages](https://askubuntu.com/q/249367) shows how to install potentially many missing packages even if you're not sure what packages they are (or see [Where are the logs for apt-get?](https://askubuntu.com/q/425809)) You shouldn't *need* to reinstall. – Eliah Kagan Jul 29 '19 at 01:42

1 Answers1

0
  1. Access Advanced options for Ubuntu in GRUB menu.

    enter image description here

  2. From the next screen select any recovery mode option.

    enter image description here

  3. From the Recovery Menu use the arrow keys to select network, press the Tab key to put the focus on <OK> and press Enter twice.

  4. From the Recovery Menu use the arrow keys to select root, press the Tab key to put the focus on <OK> and press Enter twice.

    enter image description here

  5. Reinstall sudo.

    apt install sudo && reboot
    
karel
  • 110,292
  • 102
  • 269
  • 299
  • 2
    Aren't there a couple of steps missing here? by default, `/` will be mounted read-only in recovery mode, and networking (required to download the package - unless it happens to be cached) will likely be disabled – steeldriver Jul 29 '19 at 02:02