linux下sudoers用法
在linux操作系统中,有关sudoers的用法,一直为大家所关注,如何用好这块的内容,一直也是学习的重点。
本节脚本学堂小编为大家带来sudoers的用法介绍。
一,sudoers基本介绍
The sudoers policy module determines a user's sudo privileges. It is the default sudo policy plugin. The policy is driven by the /etc/sudoers file or, optionally in LDAP. 
/etc/sudoers 用来配置管理用户sudo权限
二,sudoers基本配置
 
## Allow root to run any commands anywhere 
root    ALL=(ALL)       ALL
## Allows people in group wheel to run all commands 
# %wheel        ALL=(ALL)       ALL
## Allows people in group wheel to run all commands without a password 
# %wheel        ALL=(ALL)       NOPASSWD: ALL
## Allows members of the users group to mount and unmount the 
## cdrom as root 
# %users  ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom
讲解:root    ALL=(ALL) ALL 
root表示被授权的用户,这里是根用户; 
第一个ALL表示所有计算机; 
第二个ALL表示所有用户; 
第三个ALL表示所有命令;
通用格式 
 
(脚本学堂 www.jb200.com)小编特别推荐 >>> linux命令学习请移步linux命令大全教程中的详细内容。
例子: 
hans   ALL=(root)   useradd,userdel 
授权hans用户在所有计算机上以root身份运行useradd,userdel命令。 
%smith  ALL=(ALL)  NOPASSWD:useradd,userdel 
授权smith组全部成员在所有计算机上以所有用户的身份运行useradd,userdel命令;且运行时不必输入密码。
三,异常
提示sudo: sorry, you must have a tty to run sudo解决方法 
方法1.注释#Defaults    requiretty 
方法2.添加Defaults:user !requiretty (指定user不需要tty)
以上就是linux系统中sudoers的用法,希望对大家有所帮助。
推荐阅读:Linux常用命令大全(经典实用的Linux命令)