This question already has an answer here:
I deleted the
/etc/passwd file and cannot login now. I don't know the root password and tried lots of passwords, but none of them worked.
How can I fix this?
Here are the steps to do this graphically:
You can do the same using terminal in a live environment.
This question seems to already have the suitable answers, I will just expand on @Lekensteyn 's comment:
If you are can login just open terminal and try this :
Boot into recovery mode or from Ubuntu live Cd . Then, mount your old drive:
then reboot. That will set no passwd for root.
Then, you can login, create all of your accounts over again, etc.
You may also use the back up which is called(i think)
Edit:(another method "I don't try that before bu i think it should work also")