mac os中sudo -s和sudo su的区别

时间:2017-04-28 12:06:22

标签: linux sudo

sudo -s和sudo su都是root用户。有什么不同吗?

使用sudo -s enter image description here

与sudo su

enter image description here

1 个答案:

答案 0 :(得分:0)

来自man sudo

 -s, --shell
             Run the shell specified by the SHELL environment variable if it is set or the shell specified by the invoking user's password
             database entry.  If a command is specified, it is passed to the shell for execution via the shell's -c option.  If no command is
             specified, an interactive shell is executed.

所以-s保留你当前的shell(在这种情况下为bash),而省略它则使用root用户的shell(sh)。我自己,我更喜欢sudo -Es保留我的shell和环境变量。