Original URL: http://www.ha97.com/4001.html
I have been accustomed to direct use of root, rarely use Su, only a few days ago found Su and Su-command is an essential difference!
The default accounts for most Linux distributions are normal users, and changing the system files or executing certain commands requires root, which requires switching from the current user to the root user. The commands for switching users in Linux are Su or Su-. The day before yesterday when I used the useradd command, I realized the essential difference between the two.
I first switched to root with the SU command, but when I ran Useradd, an error occurred: Bash:useradd:command not found. Google for a bit, because of this with the SU command to switch over the root user.
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.
Linux is like this, sometimes the configuration file more or less a space, the service will not run. Details must pay attention to, so as to less detours!
"Go" (summary) The essential difference between Su and Su-commands under Linux