Debian

How to Switch Users in Debian

How_to_Switch_Users_in_Debian

Debian, sometimes known as Debian GNU/Linux, is a free and open-source Linux system developed by the Debian Project, which is supported by the community. Ian Murdock essentially started this project on August 16, 1993.

Debian is widely regarded as one of the most popular Linux-based operating systems. Debian releases new distributions on a regular basis, with the next candidate following a time-based freeze. Whether you’re using the superuser account for administrative tasks or changing the current user’s access to a specific directory, you’ll have to move between users at some point. For coping with such issues, Linux provides a number of methods. Logging out and back in as the desired user is the apparent approach. You do, however, have a few methods for switching users without logging out of the existing one.

Switch users in Debian

In this article, we’ll discover how to switch between users in Debian in a variety of methods. These methods involve:

  • Using su command
  • Using sudo command
  • Using Desktop Environment(GUI)

Switch User using su Command

You may have used the su command to elevate yourself to the level of superuser or root. This command can also be used to switch between users when another user is in the middle of a session. You can simply add the relevant username to the su command to switch to another user. here my username is “test”.

$ su test

A picture containing graphical user interface Description automatically generated

The whoami command can be used to see if the user has been changed or not.

You will be asked to enter a password if the user is password-protected or an administrator.

A picture containing logo Description automatically generated

The su command with the -c argument can assist you run terminal commands as another user if you only need to do a quick task and don’t want to switch users.

$ su –c whoami test

Chart, scatter chart Description automatically generated

The -s option can also be used in order to open the shell as a different user and run a series of commands. Use the following mentioned syntax in order to open the shell.

su <username> -s /bin/sh

Here my username is “test”, you can change the username according to your requirements.

su test -s /bin/sh

Chart Description automatically generated

Switch user using sudo command

The sudo command is another option for switching between users. To switch users, use the following below-mentioned command with the -u parameter and your username.

$ sudo -u test

Text Description automatically generated

With the following command, you can run a single command as a different user without having any changes in users.

$ sudo –u test whoami

A picture containing chart Description automatically generated

You can run the batch of instructions without switching users by opening a shell as another user. In order to open a shell, type the following command.

$ sudo –u test /bin/sh

Chart, text Description automatically generated

Switch User using Desktop Environment

The final and most common approach is to use your system GUI to logout or swap users. This mechanism is utilized by all multiuser operating systems and is not unique to Linux.

If you’re utilizing a desktop environment, you’ll need to switch between users. Select the dropdown symbol from the startup menu and click on power off/ log out option.

A screenshot of a computer Description automatically generated with low confidence

The following session dialogue will appear when you click on logout/ power off option.

Graphical user interface, application Description automatically generated

You can either select the switch user or the logout option. Both of these options will send you to the login form below.

Graphical user interface, application, Teams Description automatically generated

Complete the login process as the user you want to log in as.

Graphical user interface, application Description automatically generated

Conclusion

Most multi-user operating systems require a graphical user interface (GUI) to move between many users, Linux (Debian) allows you to log in to other user accounts using the command line. In this article, we have gone through all of the several methods you can switch between users in Linux (Debian). Advanced An understanding of the Linux command line is beneficial to any Linux user since it allows us to solve problems quickly and efficiently.

Similar Posts