Login as a Different User in Linux
Say you log in to a Linux machine but then want to switch to a different user. You can do this without logging out as the first user. A time when this might come in handy is when you are logged in as a regular user but want to install some software as the root user.
The command to do this is called su and stands for “substitute user.”
So let’s say you logged in with the Steve account. And then you want to log in as root. You would type:
su -It would prompt you for the root password. Then when you wanted to switch back to running as Steve, you would type:
exitOr if you had originally logged in as root and wanted to change to be logged in as Steve, you would type:
su SteveFor more help on how to use this command, type the following at the command line:
su --help