Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just created a new user (I was logged in as root to do so) with the adduser utility. I gave the new user his own home directory. If I check the /etc/passwd file, it shows the users home folder is correct and even when I ssh into the server as that user it starts me off in the correct folder. However, whenever I type "cd ~", it takes me to /root. Anyone know how I can fix this?

share|improve this question

There are a few things to check:

  • If you sudo to the new user using sudo -u <newuser>, make sure you pass the -H flag, so that it will set the HOME environment variable, like so: sudo -u <newuser> -H.
  • If you use su, make sure you use su - so that it will launch a login shell, which will explicitly set your HOME variable.
  • If you are logging in as this user from the get-go, you can verify that your home directory is set correctly in *sh by using echo $HOME to verify which HOME directory *sh THINKS you're using.

Hope these tips (and their explanations) help!

share|improve this answer
I was SSHing directly to the new user account. When the connection was made, It put me into the users home folder, but if I then typed "cd ~", it took me to /root. As for the other responses below, I wasn't su'ing into the user, I was logging in as the new user himself. I didn't check the uid of the user.. I didn't think two users could have the same uid? At any rate, our plans changed and I don't need this new user anymore, so it's been deleted. Thanks for all the suggestions though! – Safado Mar 28 '11 at 15:37

Did you log in as the user or did you su to the new user? If you used su, did you use su - or whatever the BSD equivalent is to make sure you use th new user's environment?

share|improve this answer

it's because youe euid is root. So you've done su or sudo to have root rights

share|improve this answer

Just to be sure, you did assign this user his own uid, and he's not using the same uid as root?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.