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.
|Description||Different ways to switch user account|
|Root or Sudo Privileges||Yes|
|Host System and Architecture||Ubuntu 22.10 (x64)|
|OS Compatibility||Ubuntu, Manjaro, Fedora, etc.|
|Discussed Tools in this Article||whoami|
Also Read: How to Switch to Root or Normal User Account in Linux
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 [USERNAME]
sudo su command
sudo su command is also similar to the previous command, except that it is mostly used by users with sudo privileges.
Also Read: How to Add User to Sudo Group
While using this command, you must know your current user password with sudo privileges.
$ sudo su [USERNAME] [sudo] password for linuxtldr:
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 [sudo] password for linuxtldr: root
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 [sudo] password for linuxtldr:
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.