为什么我没有进入 sudoers 文件却拥有超级用户权限

为什么我没有进入 sudoers 文件却拥有超级用户权限

我刚刚安装了 Ubuntu,我的用户是超级用户,可以使用 执行命令sudo。所以我以为这个用户已添加到/etc/sudoers文件中。但似乎不存在:

#
# 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        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/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

用户信息:

uid=1000(someuser) gid=1000(someuser) groups=1000(someuser),4(adm),24(cdrom),27(sudo),
30(dip),46(plugdev),113(lpadmin),128(sambashare)

我如何获得超级用户权限?

答案1

您在组中sudo。引用您的 sudoers 文件(我提请您注意有效行之前的有用注释):

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

答案2

您的用户是该群组的成员sudo

正如您在文件中看到的,sudoers该组的所有成员都有使用权限sudo

相关内容