Stands for substitute user. This command is used to switch user and lets exceuting command with the privilage of that user. It simplifies, typically for administrator, to manage users. Instead of logging to shell for separate users and sessions, admin can login with their own account and switch to sepcific user with their username.
General syntax for su
command:
$ su [OPTIONS] [USER [ARGUMENT...]]
Login with a different user account
su [username]
Pass the username to the su
command, and it will provide a login session when the password has been verified.
Example: Login with a different username newone.
Login with a different user account + run a command
su [username] -c [command]
The -c
option allows you to run a particular command under a different user account and display the results in the current login session.
Example: Running the ls
command under another user account newone and displaying it in the ubuntu login session.
Specify the shell
su -s /bin/[shell]
Use the -s
option to change an existing default shell to a different one.
Example: Using the command to open the root user account in the Z shell (zsh).
Preserve user account environment
su âÂÂp [another_user]
The -p
option allows you to keep the environment of the current user account.
Example: Switching username user to user newone. And displaying the home directory to show that it remains the same.
The post How to Use the SU Command in Linux appeared first on Hongkiat.
from Signage https://ift.tt/wYAoVvB
via Irvine Sign Company