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

linux的权力分配-sudo

时间:2014-05-15 04:08:09      阅读:320      评论:0      收藏:0      [点我收藏+]

标签:style   c   com   a   文件   使用   

         Sudo是Unix/Linux平台上的一个非常有用的工具,它允许系统管理员分配给普通用户一些合理的“权力”,让他们执行一些只有超级用户或其他特许用户才能完成的任务(主要体现为命令),比如:运行一些像mount,halt,su,useradd、userdel之类的命令,或者编辑一些系统配置文件,像/etc/mtab, /etc/samba/smb.conf等。这样以来,就不仅减少了root用户的登陆次数和管理时间,也提高了系统安全性。


在没有给一个普通用户赋予某项权利时,即使使用在使用命令之前加sudo命令,仍然不行。

[book@localhost ~]$ useradd xx
-bash: /usr/sbin/useradd: 权限不够
[book@localhost ~]$ sudo useradd xx
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.
[sudo] password for book: 
book is not in the sudoers file.  This incident will be reported.

[root@localhost book]# vim /etc/sudoers

权利分配的方法:

权力分配主要通过在配置文件/etc/sudoers按照约定格式添加一行信息。(配置该文件是要以root身份配置)
用户名主机名=(运行用户名) 可运行的命令   

例1. book ALL=(ALL) /usr/sbin/useradd                                       //假设系统里有book这个用户,对其赋予useradd权利
例2. book ALL=(ALL) NOPASSWD: /usr/sbin/useradd                //不需要密码认证

则切换到book用户下后,执行sudo useradd   xx        //普通用户book就可以增加一个用户xx


linux的权力分配-sudo,布布扣,bubuko.com

linux的权力分配-sudo

标签:style   c   com   a   文件   使用   

原文地址:http://blog.csdn.net/chun_1959/article/details/25733931

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