I have accidentally set the owner for all files and folders in the /home folder to 'root' (and a lot of other folders also) and now when I ssh into the server as myusername, I get the following error:
Could not chdir to home directory /home/myusername: Permission denied -bash: /home/myusername/.bash_profile: Permission denied
At least it lets me login, but I can't do much. I only have my user and root as users, but root can't ssh in. I can't sudo as it gives "-bash: sudo: command not found" and if I try and switch to root it states "su: Authentication failure" even though I'm using the correct password. I can cd to most folders however.
Is there any way I can switch to root or chown folders which are currently owned by root?