How to Switch between Users in Linux


Using the Linux command su (switch user), you can execute a command as a different user. This is the quickest way to switch to the administrative account when logged in as the most recent session. To make the code safer, all Linux distributions—including Ubuntu—disable the root user account by default. This limitation, however, would prevent the user from carrying out intricate instructions. This restriction can be overcome by briefly assuming root user status via su.

Continue reading if you want to learn more about the su and sudo commands. This article will cover all aspects of the sudo command and how to utilize it in Linux. Other articles can be found here: Rename or Move a File or Directory in Linux and How to Install and use Minikube on a Linux System and How to launch a free WordPress test site with TasteWP? and How to launch a free WordPress test site with TasteWP? also How to Install PlayonLinux on a Linux System


You will need terminal access and an account with sudo privileges on the Linux-based system.

Changing the Current User Using su

During a login session, the su command can be used to either change into a different user or to become the superuser. The command’s fundamental syntax is as follows:

su options username

Options refer to the many flags that can be applied to a command, and username denotes the name of the target account. Su will automatically switch to the root user if the username is left out of the command.


The system will automatically transfer the current login session to the chosen user by simply giving the username as an argument.

su username 

The the screenshot below, we switched to a user named rdgmh

switching between users

Notice that we were prompted for our password. The password of the current user that you are logged into . We can verify the change with the command:


The output will display the name of the user you just switched to. In this case: rdgmh

You don’t need to switch to another user if you simply need to execute one command as that user. Instead, you may just use the -c switch to run the command as a different user.

su -c <command> <username>

When switching between users, the su command can establish a new environment by prefixing it with a hyphen (-).

su -c

the user account is not for rdgmh, but we ran whoami and we were asked for rdgmh’s password instead of the logged in account and we were shown the result below.

-s flag

To switch to a different user while changing the shell, use the -s parameter with the command. Keep in mind that you must execute the command with the appropriate shell path:

Using the Desktop Environment to Switch Users

The graphical method is an alternative. The desktop environment that most Linux computers have installed gives you the graphical user interface you need to interact with the OS.

Changing between users in the GNOME desktop environment:

  1. The top-right corner of the screen has a downward-pointing arrow icon; click on it.
  2. Switch User from the dropdown menu by clicking Power Off/Log Out.
switching from gui

We have the option of chosing which ever user we want to use as GNOME will display a list of available users. Click on the username you want to log in as

user options


It is possible to switch between different users when using Linux and the steps can be done by following the laid down approaches for whichever method you want to use.

Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x