0

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.

  • 1
    Why not simply ssh new_user@myserver? – Jos Dec 2 '19 at 8:52
  • actually this is a really interesting question and i do not know why! what I can say is that everyone has its own user and we usually work with project_user – Mohammad Masoumi Dec 2 '19 at 8:57
1

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

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.