zoukankan      html  css  js  c++  java
  • sudoer visudo命令详解

    一般用户赋权设置:

    #
    # 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	mail_badpass
    Defaults	secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
    # Host alias specification
    # User alias specification
    # Cmnd alias specification
    # User privilege specification
    root	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
    testuser   ALL=(root) /usr/sbin/useradd         //新增加用户testuser行
    %testgroup ALL=(ALL:ALL) NOPASSWD:ALL          //新增加组testgroup行
    
    
        说明:
        第一个字段:root为能使用sudo命令的用户;
        第二个字段:第一个ALL为允许使用sudo的主机,第二个括号里的ALL为使用sudo后以什么身份(目的用户身份)来执行命令;
        第三个字:ALL为以sudo命令允许执行的命令;
    

    上列解释: test ALL=(root) /usr/sbin/useradd
    表示允许test用户从任何主机登录,以root的身份执行/usr/sbin/useradd命令。

    %ubuntu ALL=(ALL:ALL) NOPASSWD:ALL,!/bin/bash,!/bin/tcsh,!/bin/su,!/usr/bin/passwd [A-Za-z]*,!/usr/bin/passwd root,!/usr/bin/cat /etc/sudoers,!/bin/vi /etc/sudoers,!/bin/vim /etc/sudoers,!/usr/bin/vim /etc/sudoers,!/usr/sbin/visudo,!/usr/bin/sudo -i
    

    如上的指令,创建一个ubuntu用户组,并让组内用户拥有sudo权限,但是不让他乱改别人密码和乱改sudoer配置

    sudo usrmod -a -G adm,cdrom,sudo,dip,plugdev,lpadmin,lxd,sambashare testuser
    

    把用户testuser加入到一些组内

  • 相关阅读:
    Vue中发送HTTP请求
    Vuex
    vue-cli
    Vue基础2
    Vue基础1
    webpack_vue
    前言:数据库典型架构实践
    MySQL数据库优化
    解析 PHP 中 session 的实现原理以及大网站应用应该注意的问题
    Yii2.0 下的 load() 方法的使用
  • 原文地址:https://www.cnblogs.com/faberbeta/p/14079408.html
Copyright © 2011-2022 走看看