There are tons of reasons to switch to another user’s or the root user’s account; however, there are multiple ways to do so, which you are going to learn today.
Tutorial Details
Description | Different ways to switch user account |
Difficulty Level | Moderate |
Root or Sudo Privileges | Yes |
OS Compatibility | Ubuntu, Manjaro, Fedora, etc. |
Prerequisites | sudo, su |
Internet Required | No |
su command
The “su
” command is the most common way to switch to another user account. If you are the root user, it will not ask for a password.
However, if you are not a root user then you are still able to switch to another user account unless you know their account password.
$ su jake
Output:
sudo su command
The sudo su
command is also similar to the previous command, except that it is mostly used by users with sudo privileges.
While using this command, you must know your current user password with sudo privileges.
$ sudo su jake
Output:
sudo -i command
Again, it is also similar to the previous two commands.
You can use this command to execute a command as a root user without switching to the root account by specifying your current account password with sudo privileges, as shown.
$ sudo -i whoami
Output:
sudo -s command
Again, identical to the above command, “No, you are WRONG!” This command is mostly used to switch to the root user account without reading or changing any user’s environmental files.
It is best used when you want to access the root account with its $SHELL
environmental value.
$ sudo -s
Output:
That’s the final end; I’ll talk to you in the next article.
Join The Conversation
Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.