The system does not start. Did it by using rm - R accidentally. How can I recover the system?
2 Answers
You need to reinstall all applications which have files in /usr/share.
Boot system from Recovery Mode with root prompt.
Remount rootfs to read-write mode with
mount -o rw,remount /.Raise up ethernet interface and get IP address from DHCP server:
dhclient enp0s3(check correct interface name inip aorifconfig -a).Specify DNS server by
rm /etc/resolv.conf echo "nameserver 192.168.1.1" > /etc/resolv.conf(change
192.168.1.1to yours gateway/router)You need to fix the
dpkgpackage as it misses the/usr/share/dpkg/cputablefile (otherwise you will face the"E: error reading the cpu table"on any apt/apt-get command)wget dpkg -i dpkg_1.19.0.5ubuntu2.1_amd64.debor installing it from cache:
dpkg -i /var/cache/apt/archives/dpkg_*.debupdate package cache:
apt-get updatereinstall essential componenets
apt-get install --reinstall debconf linux-base mkdir /usr/share/python apt-get install --reinstall python2.7-minimal python3-minimaland then use one-liner below:
apt-get install --reinstall $(dpkg -S /usr/share/ | sed 's/,//g' | sed 's/: \/usr\/share//g')Above:
dpkg -S /usr/share/shows the list of comma-separated packagessed 's/,//g'- removes commassed 's/: \/usr\/share//g'- removes: /usr/sharein the end
This part may fail with messages about some packages. For example on my VM I have had a problem with
bsdmainutils, so I reinstalled them with:dpkg -i /var/cache/apt/archives/bsdmainutils_*.deband then reran one-liner above.
fix broken packages
dpkg --configure -a apt-get install -ffinally fix
/etc/resolv.conflink byrm /etc/resolv.conf ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.confreboot.
Note: the resulting fixed system do not show any problems while running sudo apt-get check or sudo debsums --all --changed.
Short answer: you can't and you have to reinstall the apps, as suggested by a previous answer.
However, before that, I would mount the drive in another computer and test undelete utilities which are available for ext3/ext4. A quick search in Google points to these ones:
extundelete:
easeus:
TestDisk:
How to guide:
etc.
1