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?

  • I would have thought su would work. Did you try to specify the path to sudo? e.g. /usr/bin/sudo -s – Ryan Babchishin Oct 23 '15 at 3:47
  • Thanks Ryan, but I've checked that path at there's no sign of sudo - looks like sudo hasn't been installed. I can't install it either as I can't get su access. – mhkb Oct 25 '15 at 23:05
  • The only other things I can think of are to login from the console and it that fails, to boot into single user mode. You don't have console access do you? – Ryan Babchishin Oct 26 '15 at 2:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.