Linux su command

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

Master your Linux knowledge. Experiment with our List of Top Linux commands for Beginners or Experts on your own Linux Dedicated serverSSD VPS machine or an SSH Shared Hosting account. Get your shared hosting account with a great discount of 40% OFF the regular price now!

Vladimir P.

Share
Published by
Vladimir P.