Linux Commands

How to Change User in Linux

Linux is a robust multi-user operating system. There can be numerous users accessing the system and using system resources. Having separate user accounts also offer better control over various permissions.

If there are multiple users in the system, there will be numerous occasions where you’d like to switch the current user. In this guide, check out how to change the user in Linux.

User in Linux

Linux has three types of user accounts: system, user, and root.

  • System: System processes are run under this user.
  • User: The account that general users login to by typing the username and password.
  • Root: A special user that has unrestricted privilege over every part of the system.

Depending on the interface (GUI or CLI), there are multiple ways to change the current user.

Change user in CLI

This section covers how to change users in the console. This section is applicable to any Linux distro.

Change user using su

This is the default way of changing the current user for the session. The su (switch user) command offers a simple way to switch users.

To change to a different user, use the following command structure. Once run, you’ll have to enter the password of the target user account to complete the login process.

$ su -


To verify, check the value of the USERNAME environment variable.

$ echo $USERNAME

There’s one variation of this command. If no username is specified, then su will default to the root user. In that case, the following commands are equivalent.

$ su -

$ su - root


Verify the change.

$ whoami


It’s strongly recommended not to log in as root unless you have to. If it’s just for running commands with root privilege, then the sudo tool offers more flexibility and security.

$ sudo

Change user using sudo

While sudo is mostly used for running a command with root privilege, it can also change the user. However, not every user can use sudo. The user must be added in the sudoers file located at the /etc/sudoers location. Learn how to add a user in sudoers.

Assuming the current user can use the sudo tool, to change to a different user, run the following command. Here, the user “jones” is a regular user, whereas “hector” is an administrator.

$ sudo -u  -s


Verify the action.

$ whoami


This is not where it stops. Using the sudo command, it’s also possible to run a command as a different user without logging in. The default way of using sudo is to run commands as root.

$ sudo


However, sudo also allows running a command as another user. This is what the command structure looks like.

$ sudo -u

Change users in GUI

If you’re using a desktop environment, then you can switch to a different user without running any command. The method will depend on what desktop environment you’re using.

Here, I’ll be showcasing how to change users on GNOME.

Change user in GNOME

GNOME is one of the most popular desktop environments out there. It’s available on almost any popular Linux distro. Its interface is pleasing, modern, and fluid. Of course, you can tweak it to give it a more pleasant vibe. Check out some of the best GTK3 themes for Linux. These are GNOME-compatible themes and should work on any modern version of GNOME.

To switch the user account, click the power button at the top-right corner and select “Switch User”.

Click the desired user account, enter the password, and voila!

Final thoughts

Changing user in Linux is quite an easy task. It doesn’t matter whether you’re a system admin or a casual user; the task is simple but important to know. Feel free to try out all the methods mentioned.

Happy computing!

About the author

Sidratul Muntaha

Student of CSE. I love Linux and playing with tech and gadgets. I use both Ubuntu and Linux Mint.