You are screwed. If you have physical access, the best thing you can do as a newbie user is complete re-installation. Even if you would find a way to log in, you will not be able to restore rights right. Rights are not uniform, and there are lots of files. Never mess with rights at large. I suppose you have no backups, do you?
To get access:
Plug in some bootable USB stick, (not sure if Ubuntu live has ssh
enabled, but many rescue liveCDs surely do).
Then reboot the machine with this stick, and you will be able to ssh into that system.
- From it, mount ubuntu disk to, say,
/mnt/ubuntu, and do command
chroot /mnt/ubuntu /bin/bash Voila, you are in your screwed Ubuntu as root.
Again, I suggest you use this access only to backup data and prepare headless installation. If you are not listening to advises, you can create root in your server:
passwd root. Should be working, mostly.