Home » Linux » Basic Linux Commands » How to Login as Different User in Linux ?

How to Login as Different User in Linux ?

Linux is a multi user operating system which means at one point in time, one or more than one user can login to single Linux machine can use independently.

In this post, we are going to see how to login as different user in same machine if you are already logged in with some username.

Check what is the username you are currently logged in as,

$ whoami

devlab

So, it shows us we are logged in as “devlab” user. Now, we want to login to same machine with username “git” [ git is one more user in our machine, you can use different name as per your username]

Type command “login” with sudo permission and you will be asked to enter the username and password. Please enter the username and password of the user you want to login as,

$ sudo login
devlab login: git
Password: 
Welcome to Ubuntu 21.10 (GNU/Linux 5.13.0-40-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

Last login: Fri Apr 29 07:53:15 IST 2022 on pts/0
git@devlab:~$

Now, lets check who is the current logged in user,

git@devlab:~$ whoami
git

And yes, we are successfully login as different user in Linux.

Now if you want to logoff of this user, you can just type the logout command as,

$ logout

Subscribe our Rurban Life YouTube Channel.. "Rural Life, Urban LifeStyle"

Leave a Comment