The su (short for switch user or substitute user) command is used to switch into other user accounts. If a username is not specified as an argument to the su command, it takes the root account into consideration. There are two ways of invoking this command, as follows:
- $ su - <username>: This method starts a new login shell as another username specified. It sets up the shell environment as if this was a proper login as that user in the system.
- $ su <username>: This method starts a non-login shell as the username specified. It just launches the new shell with the current user environment settings, without invoking other username shell variables.
In the absence of any username, su – invokes the root shell ...