![root 组和 sudo 组有什么区别?为什么 root 用户默认不是 sudo 组的成员?](https://linux22.com/image/1087650/root%20%E7%BB%84%E5%92%8C%20sudo%20%E7%BB%84%E6%9C%89%E4%BB%80%E4%B9%88%E5%8C%BA%E5%88%AB%EF%BC%9F%E4%B8%BA%E4%BB%80%E4%B9%88%20root%20%E7%94%A8%E6%88%B7%E9%BB%98%E8%AE%A4%E4%B8%8D%E6%98%AF%20sudo%20%E7%BB%84%E7%9A%84%E6%88%90%E5%91%98%EF%BC%9F.png)
对于此事我感到很困惑。
据我所知,用户 root 拥有所有特权。
此外,sudo 组的所有用户都拥有所有特权。
但是默认情况下,root用户不是sudo组的成员。那么root用户如何才能成为sudo用户呢?
请向我解释整个概念。
值得注意的是,下面提到的命令会产生下面提到的输出:
$root@lenovo:/home/rancho# compgen -u
-----
-----
root
rancho
-----
-----
$root@lenovo:/home/rancho# compgen -g
-----
-----
root
rancho
sudo
-----
-----
$root@lenovo:/home/rancho# getent group sudo
sudo:x:27:rancho
$root@lenovo:/home/rancho# getent group root
root:x:0
$root@lenovo:/home/rancho# visudo
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults rootpw
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
:x
$root@lenovo:/home/rancho#
答案1
你说得对根拥有所有特权,但说sudoers拥有所有权限并不完全正确。它们是允许达到使用sudo
以下命令运行命令:根。这包括运行 root 提示符,使用类似这样的命令sudo -i
。
根不是一个须知因为它已经根- 它不需要成为根运行命令。