1

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?

4 Answers 4

4

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!

1
  • 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, 2011 at 15:37
0

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?

0

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

0

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .