linux - macOS 中 sudo -s 和 sudo su 的区别

标签 linux sudo

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

使用 sudo -s enter image description here

使用 sudo su

enter image description here

最佳答案

来自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 和环境变量。

关于linux - macOS 中 sudo -s 和 sudo su 的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43679864/

相关文章:

linux - 如何根据模式将一个文件拆分为两个文件?

linux - 为特定命令添加 NOPASSWD

linux - 使用 Bash 在 "sudo -i"之后切换回之前的用户

python - 有没有办法同时使用 fabric run() 和 sudo() ?

linux - bash 脚本中的字符串替换给出错误

linux - gcc 显示 "Need native word sized stores/loads for atomicity"用于调用 `hlist_nulls_add_head_rcu`

c - 如何找到默认网关的地址和面向它的本地地址?

linux - 在 linux 脚本的帮助下从一行中提取一个整数?

security - 为什么我要为 sudo 要求一个 tty?要求它的安全好处是什么?

linux - sudoers NOPASSWD : sudo: no tty present and no askpass program specified