How to switch users on the Linux command line
Just like Windows or macOS, Linux systems also have different types of accounts and users with different system access privileges. However, not all users can execute all commands and not all users have the right to switch to another user account.
1. Overview
To switch users, we must first know the password of that user. Use the command below to switch users:
su -
To switch to root user on Ubuntu, we use the command below:
sudo -i
2. List of users on Linux
Basically Linux system has 3 types of users:
- System users
Is a user created automatically on Linux systems to be able to run services or applications.
- Regular users
Is a user who can log into the system. Each user may or may not have access to the system.
- Super User
These are system Admins or users who can perform high level tasks, which can be tasks that affect or endanger the system.
3. How to switch users on Linux command line
On Linux systems, we can log in as any user, and then switch to another user through the same command line session. To do this, we will use the "su -" command, which allows us to switch directly to another user:
For example:
johndoe@system:-$ su - janedoe
Password:
janedoe@system:-$
In the above example we need to know the password of the user janedoe to switch to that user.
4. Switch to root user
For some security reasons, some systems block direct login, local login or remote login of the root account. So to execute commands under the root user, we will have to use the sudo command .
The sudo command will basically execute anything you want on the system as if "root" did it. Importantly, you don't need to know the root user's password, in fact probably no one knows what password root is assigned.
All you need to know is the user's password and that the user must belong to the " sudoers" group, which is basically the group of users that can use the sudo command on the system.
Normally to run commands as root via sudo command, we use the command below:
sudo
In case you want to switch to root user so that all subsequent commands will run under root user, we use the command:
sudo -i
The password we use here is the user password, not the root account password.
So, in the above article, TipsMake has just guided you on how to switch users on the Linux command line. Basically, Linux systems allow users to easily switch users or execute advanced commands using the su and sudo commands.
In addition, if you have any questions or queries that need to be answered, you can leave your comments in the comment section below the article.
Creating a user in Windows 10, creating a new user account is also a question that many people who are new to using Windows 10 are wondering about. For details on creating a user in Windows 10, please find out on Taimienphi.
Also a trick on Linux operating system, changing IP address with command on Linux - one of the ways not many people know, you can refer to how to change IP address with command on Linux presented in detail on our page.
You should read it
- The best online file conversion tools for all your formatting needs
- All you know about optimizing the CRO conversion rate is wrong
- 5 best video conversion software available today
- How to use large file fileshifter.io convert
- Best free image conversion programs 2021
- How to use Max Converter convert video, audio, images
- The best online file conversion website online
- Switch from base 16 to base 2
- Convenient currency conversion feature on Opera, did you know?
- Download the PDF Conversion Tool Windows 10 application is free
- How to quickly switch between accounts in Windows 10
- New Microsoft Edge can 'disguise' as other browsers