The difference between su and su - is as follows:
-
su: This command switches the user to the specified user account (default is root) but does not load the user's environment variables. It retains the current user's environment, which means that the working directory and environment variables remain unchanged. -
su -: This command switches to the specified user account and also loads the user's environment variables as if the user had logged in directly. This includes changing to the user's home directory and setting environment variables likePATH,HOME, etc.
In summary, su - provides a full login shell for the user, while su does not.
