The hyphen has two effects:
1) switches from the current directory to the home directory of the new user (e.g., to /root in the case of the root user) by logging in as that user
2) changes the environmental variables to those of the new user as dictated by their ~/.bashrc. That is, if the first argument to su is a hyphen, the current directory and environment will be changed to what would be expected if the new user had actually logged on to a new session (rather than just taking over an existing session).
No comments:
Post a Comment