The su command is most commonly used to switch to another user. You will then be able to run commands as if you were that user and in their environment. In this article, we will show you the basic usage of the Linux su command.
Switch to another user
su anotherUser
Preserve variables
This will allow you to keep your own defined environment variables
su -m anotherUser
Switch to another user even if he doesn’t have shell access enabled (SSH)
su -s /bin/bash anotherUser