It is really simple to switch users in Ubuntu or any other Linux distribution using the terminal.
All you need to do is to know the unsername and its account password and you can switch users with su command:
su another_username
You’ll be asked to enter the password of the user you want to switch to.
As you can see in the screenshot above, I changed to user prakash from user abhishek in the terminal.
There are some minor details with this method that I’ll share with you in a moment. I’ll also share the graphical way of switching users in Linux if you are using desktop Linux.
Switching to root user
If you want to switch to the root user in Ubuntu, you can use the following command:
sudo su
You’ll have to enter your own user password here.
Change user in Linux command line
Let’s see things a bit in detail. To switch users, you need to first know the exact username because tab competition doesn’t work here. You can list all the users in Linux command line by viewing the content of the /etc/passwd file.
You’ll also need to know the password of the user account you want to switch to. This is for security reason, of course.
su another_username
If you are the admin user or have sudo access, you can change account password with passwd command.
You’ll notice that some people use a -
between su and the username. There is a specific reason for that.
su - another_username
When you use -, -l or –login option, you start the shell as a login shell. This means that it will initialize the environment variables like PATH and changes to the home directory of the changed user. It will be as if you logged into the terminal as the second user.
Note: though -
is more popular, it is advised to use –login option.
Change users in Linux graphically (for desktop Linux)
If you are using desktop Linux, the above method may not be sufficient for you. Why? Because you switch the user in the terminal only. It is confined to the terminal. Nothing is changed outside the terminal.
If you want to switch users so that you can log in as another user and use all the system (browser, applications etc) graphically, you’ll have to log out and then log back in.
Now the screenshots may look different but the steps remain the same. Here’s how to switch users in Ubuntu Linux.
Go to the top right corner and click the Power Off/Log out option to open the dropdown and you can choose either of Switch User or Log Out.
- Switch User: You get to keep your session active (applications keep on running) for current user. Good for temporarily switching users as you won’t lose your work.
- Log out: Current session ends (all applications are closed). Good when you want to switch to the other user for a long time.
You can choose whichever option is more suited for your need.
Now, you’ll be at the login screen with all the available users for your system. Choose the user account of your choice.
Clearly, you need to know the password of the user account you want to use.
That’s it. I hope you find this quick beginner tip helpful in changing users in Ubuntu and other Linux distributions. Questions and suggestions are always welcome.
from It's FOSS https://ift.tt/2EBzHOE
via IFTTT
No comments:
Post a Comment