I log into an system as root via ssh.
How do I become the normal user or another user in the command-line?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
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.
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
suis 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
sucommand. 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
you can then return to the previous user by entering