Switch from normal user to root user:
You can use Su or Su-:
The most essential difference between the SU command and the Su-command is that the former simply switches the root identity, but the shell environment is still the shell of the normal user, and the user and the shell environment are switched to root. The PATH environment variable error does not occur unless you switch the shell environment. After the SU switch to the root user, PWD, found that the working directory is still the normal user's working directory, and after the Su-command switch, the working directory becomes the working directory of root. Use the echo $PATH command to see how the Su and Su-future environment variables are different. And so on, to switch from the current user to another user, you should use the Su-command.
Switch from root user to normal User:
Example: Switching from root to deploy user
If you use the SU deploy
If you use Su-deploy
Su without--does not read the target user's environment profile, and the band-Su will read it.
There are "-" and none "-" the respective environment variables are different
The difference between Su and SU under Linux and the problems encountered in practice