Blog · TrumanWong
Linux为用户授予sudo访问权限
在Linux中我们可以授予 sudo 访问权限来允许非 root 用户执行管理命令。sudo 命令在不使用 root 用户密码的情况下为用户提供管理访问。
当用户需要执行管理命令时,可以使用 sudo 命令前执行该命令。然后用户就有了 root 用户的权限执行该命令。
请注意以下限制:
先决条件
流程
-
以 root 身份,打开
/etc/sudoers文件。# visudo/etc/sudoers文件定义sudo命令应用的策略。 -
在
/etc/sudoers文件中,找到为wheel管理组中用户授予sudo访问权限的行。## Allows people in group wheel to run all commands %wheel ALL=(ALL) ALL -
确保以
%wheel开头的行前面没有#注释符。 -
保存所有更改并退出编辑器。
-
将您要授予
sudo访问权限的用户添加到wheel管理组中。# usermod --append -G wheel <username>将 <username> 替换为用户的名称。
验证步骤


