Switch to current home user directory after switching user in Ubuntu

I created a new user on my Linux machine with the following commands

sudo useradd -m foo.bar
sudo passwd foo.bar

After that, I switch to foo.bar, but the current directory does not direct to the current user and the info of the current user does not show in the command line

ubuntu@ip-172-31-47-200:~$ su foo.bar
Password:
$
$ whoami
foo.bar
$
$ pwd
/home/ubuntu

I would like to have something like

foo.bar@ip-172-31-47-200:~$

How can I achieve this?

4

1 Answer

what you're looking for is the flag '-l'. You can directly access a users home-directory + initialize path-variables etc. by using "su -l user", where user is the username you're logging in with.

More information: su man-page

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like