How to Switch Users in Debian


Debian is a popular Linux-based operating system that frequently launches new variants. There are different users in the Debian OS that have different privileges and rights, so you might need to switch between them to have access of any specific files and folder.

Linux has several remedies for these issues, one of which is to sign out and then sign back in as the proper user. However, there are a few ways to move between users without logging out of the current one which are as follows.

Using su command

It’s possible that you ascended to the superuser or root level using the su command. To switch to a different user, just add the appropriate username to the su command as seen below:

$ su test

How-Switch-Users-Debian

You could verify if you successfully switched to a different user by using a whoami command. If you simply need to do a brief operation and don’t want to swap users, the su command with the -c parameter can let you execute terminal commands as another user.

$ su –c whoami test

How-Switch-Users-Debian

By launching the shell with the -s option, you may run a number of commands as a certain user while using the syntax that is shown below.

su <username> -s /bin/sh

How-Switch-Users-Debian

Using sudo Command

By using the command listed below with the -u argument and your username, you can also use the sudo command to swap between users.

$ sudo -u test

How-Switch-Users-Debian

You can execute a single task as a various user without changing users by using the following command.

$ sudo –u test whoami

How-Switch-Users-Debian

You can also run multiple commands all at once by creating a bash script and place your desired commands inside that script as shown below.

$ sudo –u test /bin/sh

How-Switch-Users-Debian

Using Desktop Environment

The fourth and most popular method is to switch users or logout using the system GUI. All multiuser operating systems employ this method; it is not specific to Linux.

You must switch between users if you’re using a desktop environment. From the starting menu, choose the drop-down icon, then click the power off/logout option.

How-Switch-Users-Debian

When you select the option to log out or power down, the following session dialogue will show.

How-Switch-Users-Debian

You can choose to sign out or switch users, and whichever option you select will take you to the sign-in form below.

How-Switch-Users-Debian

You will see a list of different users and you can sign in from any of the desired one you like.

How-Switch-Users-Debian

Conclusion

Most multi-user operating systems need a graphical user interface (GUI) to switch between numerous users, although Linux (Debian) enables command-line login for other user accounts. In this post, we’ve reviewed all the various methods for switching between users in Linux (Debian). Advanced Any Linux user may benefit from knowing the Linux command line since it enables rapid and effective problem-solving.

Print Friendly, PDF & Email
Categories