su user 与 su - user 之间的区别

The difference between "-" and "no hyphen(连字符)" is that the latter keeps your existing environment (variables, etc); the former creates a new environment (with the settings of the actual user, not your own).php

区别:su - 会带上用户自己所执行的环境。若是不加上,仍是使用自己的参数。linux

参考博文:http://superuser.com/questions/453988/whats-the-difference-between-su-with-and-without-hyphenbash

https://wiki.archlinux.org/index.php/Susession

The hyphen has two effects:spa

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 userorm

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).blog

也能够参考博文:http://freebile.blog.51cto.com/447744/530937get

相关文章
相关标签/搜索