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-.
As shown in the beginning is a normal account, when the execution of Userdel, prompt command not found, through the SU command to the root user, still prompt command not found, exit, re-through the Su-command, the successful implementation of Userdel command execution.
The biggest 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.
As shown in the following:
After the SU command switches to root user, PWD, found that the working directory is still the normal user's working directory;
With 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.