码迷,mamicode.com
首页 > 系统相关 > 详细

Linux 之 用户管理权限visudo

时间:2018-05-15 17:26:11      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:VISUDO

用户管理权限visudo
实例:创建用户kang,授于yum 权限,useradd 权限
[root@localhost ~]# useradd kang
[root@localhost ~]# passwd kang
Changing password for user kang.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@localhost ~]# tail -1 /etc/passwd
kang:x:501:502::/home/kang:/bin/bash
[root@localhost ~]# visudo                                 #开通yum与useradd权限,如需开通所有权限请用ALL
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
zabbix  ALL=(ALL)       ALL
kang    ALL=(ALL)      /usr/sbin/useradd,/usr/bin/yum
[kang@localhost ~]$ sudo reboot               #reboot 没有权限
[sudo] password for kang: 
Sorry, user kang is not allowed to execute ‘/sbin/reboot‘ as root on localhost.localdomain.
[kang@localhost ~]$ sudo useradd test
[sudo] password for kang: 
[kang@localhost ~]$ tail -2 /etc/passwd
kang:x:501:502::/home/kang:/bin/bash
test:x:502:503::/home/test:/bin/bash

[root@localhost ~]# visudo -c      #配置文语法检查
/etc/sudoers: parsed OK

用户别名,命令别名使用技巧

[root@localhost ~]# visudo 
User_Alias ADMIN = kang, test                 #ADMIN包括了用户kang, test 
Cmnd_Alias USERCMD = /usr/sbin/useradd                  #USERCMD包括可用useradd命令权限
Cmnd_Alias NETWORKCMD = /sbin/ifconfig,/etc/init.d/network           #NETWORKCMD命令包括ifconfig/network命令

ADMIN       ALL=(ALL)     USERCMD, NETWORKCMD               #授权用户命令使用

备注解释使用

root                     ALL=(ALL)                    ALL
用户/组               机器=角色                    命令

# User_Alias ADMINS = jsmith, mikem
# Cmnd_Alias NETWORKING = /sbin/route, /sbin/ifconfig, /bin/ping, /sbin/dhclient, /usr/bin/net, /sbin/iptables, /usr/bin/rfcomm, /usr/bin/wvdial, /sbin/iwconfig

Linux 之 用户管理权限visudo

标签:VISUDO

原文地址:http://blog.51cto.com/12965094/2116443

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!