mac os 中 sudo -s 和 sudo su 的区别
Difference between sudo -s and sudo su in mac os
sudo -s 和 sudo su 都使用户成为 root。有什么不同吗?
使用 sudo -s
使用 sudo su
来自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 用户 (sh) 的 shell。我个人更喜欢 sudo -Es
保留我的 shell 和环境变量。
sudo -s 和 sudo su 都使用户成为 root。有什么不同吗?
使用 sudo -s
使用 sudo su
来自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 用户 (sh) 的 shell。我个人更喜欢 sudo -Es
保留我的 shell 和环境变量。