When you login to your dedicated server via SSH, there are normally two options: your own username and root. It is inadvisable to login directly as root, but you can always use “su” or “sudo” to run root commands. In some circumstances, however, it may actually be more convenient and useful to login as another user rather than as root. To do this, you can use the same tool, “su”.
To login as another user, simply type:
su — username
Replace “username” with the actual username of the user you want to log in as, and the system will then prompt you for that user’s password.
Why would you ever want to do this? There are a few possibilities. One is that you may need to run a script under a particular username because that script will set file permissions and settings for that user. If you run them as root, you will have to go back and manually adjust all of the files and directories. Another possibility is that you need a test user to experiment with some commands, tools, or scripts. Run those tools as root and you could destroy your server. Run them as a test user, and the worst you could do is ruin a user you did not really need in the first place.
When you are finished doing whatever you needed to do, be sure to type “exit” to leave that login account. Otherwise, you may end up running tasks with the wrong username.