Simple Answer
Reinstall Ubuntu
You've effectively gutted your system. If there's nothing really important on it, then I'd just do that as it will take you about 30 mins to an hour to get back to a working system on standard machine.
USB key recovery
Alternate Ubuntu install disk - Fix a Broken System
You could also download the Ubuntu USB key alternate version and boot from it, and then select the "Fix a broken system" option. This does a bunch of stuff like fix your MBR and check filesystem files.
Advanced answer
I've saved clients from worse mess-ups than this.
If you have access to another Ubuntu machine of the same type, or you can download and unzip the dpkg package for your architecture from your local mirror (e.g. https://packages.ubuntu.com/bionic/dpkg) then you could manually copy the dpkg program back into its original location.
As alluded to in the comments, this may not be your only problem. Once you have some semblance of dpkg
and apt
up and running again, if you can, I'd install the debsums
package and recommend checking your other packages against the known checksums of the packages you already have installed.
e.g.
dpkg -l | awk '/^ii/ { print $2 }' | xargs debsums | grep -vE 'OK$'
Then for each package mentioned:
apt-get --reinstall <package>
Then, after going through the output of that and making sure you have everything, I'd reinstall the ubuntu-core
and ubuntu-desktop
or ubuntu-server
package also, which should bring everything back to a running state.
dpkg
application, you have gutted your package manager. dpkg is the application that actually installs and removes packages - apt merely computes and queues dpkg instructions and manages the repositories. Time to backup your data and reinstall. – user535733 Oct 10 '18 at 2:02