0

I am in a big problem. Everything was running ok, then I tried to install MongoDB, I was getting dpkg: unrecoverable fatal error, aborting: statoverride file contains empty line errors and was not able to install MongoDB. By mistake, I run sudo apt remove dpkg. After that, no Linux commands are getting run. I am worried if my WSL ubuntu 18.04 is crashed. How can I recover this issue? I don't want to lose any work files. Please help.

Edit: When I run the command sudo apt remove dpkg after some time, it opened a screen asking OK or CANCEL. I did not understand and I close the terminal directly. So, I am really not getting what exactly happened. After that, I cannot run sudo apt like commands.

Varsh
  • 101
  • 2
    apt is a wrapper that uses dpkg to install packages, so if you removed dpkg you should not expect tools that use it to work (eg. apt, apt-get, aptitude etc). Restoration of backups may be best, but dpkg should not impact other commands, just the deb package install programs won't be able to install/remove etc. (dpkg can't download packages, so apt and front-end tools give the simpler tools greater functionality, calling the base programs to do the work as required) – guiverc Feb 09 '21 at 04:04
  • So can I restore the dpkg package? – Varsh Feb 09 '21 at 04:24
  • 1
    Reinstall dpkg. See: https://askubuntu.com/questions/878887/how-to-reinstall-dpkg – Phillip Remaker Feb 09 '21 at 04:32
  • The commands to reinstall dpkg also gives errors. Like for the command cp /var/backups/dpkg.status.0 /var/lib/dpkg/status gives cp: cannot stat '/var/backups/dpkg.status.0': No such file or directory – Varsh Feb 09 '21 at 05:57
  • The "how to reinstall dpkg" reference is a corrupted dpkg and not a removed dpkg, however the second (1 upvote currently) example better suits your condition (as it re-installs rather than fixed a corrupted dpkg as the most upvoted answer does); but you'll of course need to adapt that (which was for a now-outdated xenial and not your bionic) – guiverc Feb 09 '21 at 06:04
  • The problem is for re-installing, grep command is needed. In my case: ./configure: line 1649: grep: command not found – Varsh Feb 09 '21 at 06:22
  • So get grep too (why I suggested backups). You can explore you apt history (/var/log/apt/history.log) to see what you removed, and what you need to re-install as well (or did you purge and not remove? .. depends rules may have meant you removed a number of packages that needed dpkg). FYI: It's best if you add additional details to your question (you can edit your own questions) as details are easier to read there, and more people will see it, and don't hit "Y" (or yes; esp. '-y') to do it, until you've assessed the damage of commands – guiverc Feb 09 '21 at 06:26
  • Please check the Edit. – Varsh Feb 09 '21 at 06:38

0 Answers0