Question: How to Switch User in Linux?
Contents

The su Command.

To change to a different user and create a session as if the other user had logged in from a command prompt, type “su -” followed by a space and the target user’s username.

Type the target user’s password when prompted.

What command is used to switching between users in Unix?

su command is used to switch the current user to another user from SSH. If you are in the shell under your “username”, you can change it to another user (say root) using the su command.

How do I change to root user in Linux?

To get root access, you can use one of a variety of methods:

  • Run sudo <command> and type in your login password, if prompted, to run only that instance of the command as root.
  • Run sudo -i .
  • Use the su (substitute user) command to get a root shell.
  • Run sudo -s .
Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest