Technology

How to Change Between Users on Linux

Since Linux is a multi-user working system, ultimately you will really feel the necessity to change between customers. Whether or not it’s for performing administrative actions utilizing the superuser account, or just altering the present consumer to entry a selected listing, Linux offers a number of methods to deal with such points.

Let’s check out how one can change between a number of customers on Linux.

Altering the Present Consumer Utilizing su

In response to the su man page, the su command is used to both change into one other consumer throughout a login session or change to the superuser. The fundamental syntax for the command is:

su choices username

…the place choices are the varied flags that you should utilize with the command and username is the title of the goal account.

For those who do not point out the username within the command, then su will change to the basis consumer by default.

su

Merely passing the username as an argument within the command will change the present login session to the required consumer.

su username

You may be requested to enter a password in case the consumer has one for his or her account.

For instance, to change to a consumer named testuser:

su testuser

Situation any of the next instructions to confirm the change:

whoami
echo $USERNAME

The output will show the title of the consumer you simply switched to. On this case:

testuser

If you must run solely a single command as one other consumer, you need not change to that consumer. As an alternative, you’ll be able to merely execute the command as one other consumer utilizing the -c flag.

su -c command username

For instance:

su -c chmod +w /Downloads testuser

Including a hyphen () to the su command will create a brand new setting whereas switching between customers.

su - testuser

Use the -s flag with the command to alter the shell whereas switching to a different consumer. Be aware that you will have to invoke the command with a shell path as follows:

su testuser -s /bin/zsh

Associated: Sudo vs. su: Which Command Should You Use?

Utilizing sudo to Change Between Customers

Much like the su command, it’s also possible to change the present consumer utilizing sudo. The syntax for each instructions is kind of the identical, apart from the choices.

To vary the present login session to a different consumer, use the -u flag:

sudo -u username

If you wish to situation a selected command as one other consumer, specify it within the command:

sudo -u username command

For instance:

sudo -u testuser chmod 777 /Paperwork

You too can change the shell whereas switching between customers:

sudo -u username path-to-shell

For instance, to change the current shell to zsh and change to testuser concurrently:

sudo -u testuser /bin/zsh

Once more, confirm if the modifications have been efficiently made utilizing the whoami command or the USERNAME setting variable.

Altering Customers Utilizing the Desktop Setting

If utilizing the command line is just not your cup of tea, you’ll be able to go for the graphical method as a substitute. Most Linux PCs have a desktop setting put in that gives the graphical interface you should work together with the OS. GNOME and KDE are two of the most widely-used desktop environments, so this information will solely deal with these.

To modify between customers on the GNOME desktop setting:

  1. Click on on the downwards arrow icon situated on the top-right nook of the display screen.
  2. Click on on Energy Off/Log Out and choose the Change Consumer choice from the dropdown menu.

    switching users in gnome

  3. GNOME will show an inventory of obtainable customers. Click on on the username you wish to log in as.

    gnome list of users

For individuals who are utilizing KDE, observe the steps given beneath to alter the present consumer:

  1. Open the Utility Launcher and click on on the Go away choice situated on the underside proper of the window.
  2. Within the dropdown that seems, choose Change Consumer.

    switch user in kde

  3. You will be taken again to the login display screen. Spotlight the consumer you wish to change to utilizing the proper and left cursor keys.
  4. Sort within the account password and hit Enter to log in.

Be aware that different desktop environments additionally provide comparable choices to log in as one other consumer.

Managing A number of Consumer Accounts on Linux

Like different working programs, you’ll be able to change between a number of customers on Linux as effectively. Though different OSes like Home windows and macOS present a GUI to hold out such actions, on Linux, you should utilize the command line to log in to different consumer accounts effectively.

As apparent, having superior information of the Linux command line is a strong addition to any IT skilled’s arsenal. Getting sensible with the instructions and holding a devoted studying useful resource at your disposal is one of the simplest ways to familiarize your self with the Linux terminal.


most-used-linux-terminal-cmds
The Linux Commands Reference Cheat Sheet

This simple cheat sheet will help you get comfortable with the Linux command line terminal in no time.

Read Next


About The Writer

https://www.makeuseof.com/linux-change-user/ | Change Between Customers on Linux

Sportset

Fry Electronics is an automatic aggregator of the all world’s media. In each content, the hyperlink to the primary source is specified. All trademarks belong to their rightful owners, all materials to their authors. If you are the owner of the content and do not want us to publish your materials, please contact us by email – admin@fry-electronics.com. The content will be deleted within 24 hours.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

2 × one =

Back to top button