I log into an system as root via ssh.
How do I become the normal user or another user in the command-line?
I log into an system as root via ssh.
How do I become the normal user or another user in the command-line?
As root, you may issue
su - username
You will not be prompted for a password.
At the command prompt, type:
su -l <normal user>
su
is the linux command to Switch User. The -l
command line option will open the new terminal session with the user's environment variables.
A secure way is:
$ sudo su - [userid]
Under normal circumstances you might not give just any use sudoer access. Also you don't want to give root remote ssh access. So you would log in under your own userID (or an ID with sudoer access) then execute the command similar to the first answer, but using "sudo".
As mentioned in some of the other commands the "-" will give you the users environment. You will inadvertently be running as that user.
sudo
, su
doesn't need to be involved. sudo -su <userid>
for a normal shell, sudo -iu <userid>
for a login shell.
– muru
Jun 21 '15 at 14:28
sudo su - [userid]
into that user.
– L. D. James
Jun 21 '15 at 16:09
penguintutor.com/linux/useradmin-reference
Excerpt:
su
(Switch User)One of the features of Linux is the ability to change userid when logged into a system. This command su is sometimes referred to as superuser , however this is not completely correct. In the early days of UNIX it was only possible to change to the root user, which made for the superuser command however it is now possible to change to any user using the su command. It is more correct to refer to the command as the switch user command.
The switch user command
su
is used to change between different users on a system, without having to logout. The most common use is to to change to the root user, but it can be used to switch to any user depending upon the users settings. To switch to a different user other than root, then the username is used as the last option on the command.It is also possible to change to another user by putting the username after the
su
command. There are two ways of switching users. By putting a '-' after the command will cause the users profile to be read and variables to be set. Without the '-' the previous users settings will still remain.To use the new users profile and variables
su - username
To continue with the current profile and variables
su username
you can then return to the previous user by entering
exit
.
root
to normal-user on a system which I have and active terminal session running. This question got alot of down-votes so I found out how to do it and this answers my question. It's simple su
lets me change users and your not the first to mention security which I still don't understand the relevance to this.
– somethingSomething
Jun 21 '15 at 04:12
It's su - <username>
. However you really want to deny root access via ssh! Refer to /etc/ssh/sshd.conf
and the setting PermitRootLogin no
.