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

相關文章
相關標籤/搜索