我已经编辑了我的权限文件并设置了 2 个用户帐户 -premlaks 和具有 sudo 访问权限的 stack。
设置完成后,我登录到 stack 用户并尝试更改几个文件的权限,但仍然不起作用...我必须将 sudo 附加到任何命令。
我认为一旦我授予 sudo 访问权限,我就可以执行任何命令。
# 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 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
premlaks ALL=(ALL:ALL) ALL
stack 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
答案1
您必须使用usermod
命令将该用户添加到 sudo 组。
例如,对我来说,这将是这样的
usermod --groups serg,sudo serg
更多信息请参见man usermod
,例如
-G, --groups GROUP1[,GROUP2,...[,GROUPN]]]
A list of supplementary groups which the user is also a member of.
Each group is separated from the next by a comma, with no intervening
whitespace. The groups are subject to the same restrictions as the
group given with the -g option.