Phoenix Asked: 2019-12-03 00:39:41 +0800 CST2019-12-03 00:39:41 +0800 CST 2019-12-03 00:39:41 +0800 CST How can switch user when login to ubuntu server 772 Question: How can I switch user automatically when I log in to an Ubuntu18.04 server? For example: I want to switch from ubuntu user to new_user user: # from ubuntu@myserver:~$ # to new_user@myserver:~/some_dir$ Thanks. directory users 18.04 1 Answers Voted Best Answer Wayne Vosberg 2019-12-03T00:50:13+08:002019-12-03T00:50:13+08:00 To truly switch user ID use: $ sudo -s -u new_user or $ su --login new_user If you only need to switch your current directory: $ cd ~new_user To do this automatically at login add the commands to ~ubuntu/.bashrc
To truly switch user ID use:
$ sudo -s -u new_user
or
$ su --login new_user
If you only need to switch your current directory:
$ cd ~new_user
To do this automatically at login add the commands to ~ubuntu/.bashrc