su user 与 su - user 之间的区别
博客专区 > Oscarfff 的博客 > 博客详情
su user 与 su - user 之间的区别
Oscarfff 发表于2年前
su user 与 su - user 之间的区别
  • 发表于 2年前
  • 阅读 100
  • 收藏 3
  • 点赞 1
  • 评论 0

腾讯云 技术升级10大核心产品年终让利>>>   

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

区别:su - 会带上用户本身所执行的环境。如果不加上,还是使用本身的参数。

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

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

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

也可以参考博文:http://freebile.blog.51cto.com/447744/530937

共有 人打赏支持
粉丝 71
博文 801
码字总数 96852
×
Oscarfff
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: