How to automatically switch to home directory when switching user?
5,746
Try to us su - otheruser
command which starts the shell as a login shell with an environment similar to a real login:
- it clears all the environment variables except TERM
- it initializes the environment variables HOME, SHELL, USER, LOGNAME, and PATH
- it changes to the target user's home directory
- it sets argv[0] of the shell to '-' in order to make the shell a login shell
Related videos on Youtube
Author by
Admin
Updated on September 18, 2022Comments
-
Admin over 1 year
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?