I accidently removed the whole /etc folder (rm -f /etc) please don't ask why I was in a rush. Then I panicked and restarted my computer. Now all I have is GRUB. Is there a way to recover my data? I'm on Ubuntu 16.04

2 Answers 2

  1. /etc does not contain the package manager database.
  2. There's no need to reinstall anything as you can simply boot from a LiveCD and reinstall all the packages and then add back your user account.
  3. As for network settings, you'll be able to reconfigure networking in your desktop environment.
  • This is true, but it depends on what was in /etc besides what's there at install. If he had anything else, such as configs for things like MySQL, Nginx, Apache, etc it might be better to just reinstall. /etc/sudoers, /etc/group, and /etc/password have also been removed. It's up to the OP, but it may be better to just reinstall. Dec 16, 2020 at 17:00
  • Packages reinstall and distro reinstall in most cases are very similar if not exactly the same. Again, there's no need tor reinstall. Dec 16, 2020 at 21:15
  • He doesn't need to reinstall any packages. Where he might run into issues is that any system configs including those for hardware, software packages, etc have been wiped out as well as users, groups, passwords, and so on. For those reasons, there would absolutely be a need for a reinstall. The same has been suggested when this same question has come up here and Serverfault on quite a few occasions. In his case, it might not be a big deal if the system was fresh but otherwise, a reinstall is best. If he had deleted /home, that would be one thing but this is /etc. Dec 16, 2020 at 23:26

/etc/ contains, to start with, all of the system config files for things such as the the network interfaces, the security and sudoer files, cron, and system-wdie shell init files. With it having been removed, those things aren't going to function any more. The best that you can try to do is boot into a live USB, mount the root partition, and copy it back but even if it does boot, it's going to take massive amount of reconfiguration and considering that all of the system configs have been wiped out, it's really not worth it. If you have a working backup, you can attempt to restore from there but if not, your best bet is a complete reinstall.

Fortunately, if you have data on the system, you can boot into a live USB and mount an external drive and copy the data there so that you can restore it after reinstalling

Edit It's actually /var that contains the package database, not /etc (that's an error on my part). The rest of the configs that are in /etc have still been wiped out. Depending on the extent of all this, it may be easier to just re-install as attempting to put everything back may be just as tedious (if not moreso).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .