5

When i ssh to my ubuntu server, i get logged in to my user's home folder.

But when i do su otheruser and enter the password, i get logged in as the otheruser but the home directory stays for the previous user.

How to automatically switch to the logged user's home dir?

1 Answer 1

14

Try to us su - otheruser command which starts the shell as a login shell with an environment similar to a real login:

  1. it clears all the environment variables except TERM
  2. it initializes the environment variables HOME, SHELL, USER, LOGNAME, and PATH
  3. it changes to the target user's home directory
  4. it sets argv[0] of the shell to '-' in order to make the shell a login shell

You must log in to answer this question.

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