su Linux Command
su Linux Command
The su command stands for substitute user in Linux. It is used to switch to a particular user and requires the user’s password to whom we are trying to switch.
$ su <user account>
su command Examples
$ su
When the command is called without arguments, it defaults to the root user. This command will prompt you for the root user’s password. Once entered, you will be logged in as the root user.
For example, if we want to switch to john user account.
$ su – john
The (-) switch allows to include john’s environment variables and the path during the switch. So, to switch to root user with root’s environment we can use:
$ su –
-c (command):
$ su -c “command” username
Allows you to run a specific command as another user without switching to their shell.
The sudo command is often preferred over the su command for executing commands with superuser privileges, as it can be configured to allow specific permissions without sharing the root password.
Linux Commands
Linux Basic Commands Tutorial page:
More Information on Ubuntu Linux: