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.|
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
sudo su command
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
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 -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
That’s the final end; I’ll talk to you in the next article.