Hopefully you have a LiveUSB or LiveCD to boot from. In the event that you did end up deleting enough to crash your system, you can boot to a Live media and select "Try Ubuntu".
There are some option to "undelete" files with programs like extundelete
, photorec
, foremost
and scalpel
. But some of these can become a nightmare to use, especially if you're not even sure what got deleted.
Another option that I recommend is to reinstall, and preserve your /home directory.
Once booted to your Live media, you now have the opportunity to make a backup of your /home folder, provided it wasn't already deleted. If you /home folder was deleted, you may want to consider using one of the above mentioned software if you feel that the files were really important.
Otherwise, go ahead and make a backup copy of your /home folder to another disk such as a USB stick, or another internal disk if you have one.
Use rsync
to do this like so rsync -avz /home /location/of/where/youre/backing
Now in the Live session, there should be a shortcut on the launcher or the desktop called "Install Ubuntu". If not, just reboot again to the Live media and select "Install Ubuntu".
In the installation portion, when you reach the partitioning page, click on "Something Else". Here you will see your partitions. Edit the one that had your Ubuntu installed to it, and set it as the same format as before (ext2/3 etc) and mount as root (/). Ensure the checkbox to format is UNCHECKED!
Do the same thing with your SWAP partition. If you had a your /home folder or any other folders mounted on other partitions, make sure you also select those to be remounted how they were before. Again, with the format option unchecked.
Continue with the installation. This installation will reinstall the entire OS, and will overwrite everything but it will NOT delete anything in your /home folder or anywhere else. So all your files will still be there. When you get to the last part of the installation to create a user, make sure you use the exact same username and same password.
Reboot and see if all your files and settings are there. You may have to reinstall some programs, but you'll find that after you install the programs, all your settings will still be there. Example is if you reinstall Chrome, your history, bookmarks etc will appear.
If you ARE missing files, boot back into the Live media, plug in or mount the drive where you made a backup of your home folder, mount your Ubuntu partition, and do rsync the other way around.
rsync -avz /location/of/your/backup/home /location/of/your/mounted/ubuntu
This should restore everything.
rm
to finish but in this questions's case it was interrupted which might need different approaches – azerafati Jul 16 '16 at 07:38rm
already has a check if you add-I
(prompt if deleting more than 3 files) and if you try torm
over/
. – Andrea Lazzarotto Jul 17 '16 at 13:33