I have accidentally removed /etc/ folder.
Now there is no way to do any administration, because
/etc/shadow are lost.
Is there any way to restore it in Ubuntu?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
Here is how I would proceed.
If you want to try to manually recover, boot the ubuntu live CD and update everything
sudo apt-get update && sudo apt-get -y dist-upgrade
You then mount your ubuntu partition at
sudo -i mount /dev/sdxy /mnt
You can the copy /etc to
cp -Raf /etc /mnt
You will then need to manually edit
The format should be easy enough to understand from existing entries, but if not ask. Make sure your user is in the admin group.
Add in your user to those files ^^
sudo chroot /mnt
And set your user password
You also need to update
/mnt/etc/fstab , define your root partition and swap. You can use the live CD as a template for most of the entries.
reboot and hope it works.
If not, boot the live CD and back up your data to a flash driver or alternate partition and re-install.
Best of luck
Restore from backup, or reinstall. If you reinstall, use manual partitioning, and do not check the format box and your personal data should remain intact. More recent releases also have the option to reinstall/replace the existing install, without formatting. This is easier to use than manual partitioning.
Restoring files from ext4 is not really easy :-/
You could start from the Live CD and copy all the files from there into your /etc directory. But I fear that will not work.
A clean install should give you better results in less time, but everything will be lost. Personal data has to be backed up before!
You can get a list of all installed packages with
and you can reinstall packages with
sudo apt-get --reinstall install packagenames
With those two commands one could build one command which reinstalls all installed packages. This could help. However, I do not have the time now, to create this command for you. If someone has time - please just edit this posting.