zoukankan      html  css  js  c++  java
  • RHEL 6.4中解决xx用户不在sudoers列表,此事将被报告的问题

    1.使用sudo service iptables status命令时报告没有权限:

    [tansheng@localhost ~]$ sudo service iptables status
    [sudo] password for tansheng: 
    tansheng 不在 sudoers 文件中。此事将被报告。
    [tansheng@localhost ~]$ 

    2.从网上搜索得知需要修改/etc/sudoers文件,但是该文件对root用户都只有只读权限,后来查到linux已经预留了专门的命令visudo来编辑该文件:

    [tansheng@localhost ~]$ visudo
    visudo:/etc/sudoers:权限不够
    visudo:/etc/sudoers:权限不够
    [tansheng@localhost ~]$ su - root
    密码:
    -bash: EDITOR: command not found
    [root@localhost ~]# visudo
    visudo:/etc/sudoers.tmp 未更改
    [root@localhost ~]# 

    3.在切换到root用户下,用visudo编辑/etc/sudoers文件,加入一行:tansheng     ALL=(ALL)     ALL

    ## Syntax:
    ##
    ##      user    MACHINE=COMMANDS
    ##
    ## The COMMANDS section may have other options added to it.
    ##
    ## Allow root to run any commands anywhere
    root    ALL=(ALL)       ALL
    
    ## Allows members of the 'sys' group to run networking, software,
    ## service management apps and more.
    # %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS
    
    ## Allows people in group wheel to run all commands
    # %wheel        ALL=(ALL)       ALL
    tansheng       ALL=(ALL)    ALL
    
    ## Same thing without a password
    # %wheel        ALL=(ALL)       NOPASSWD: ALL
    
    ## Allows members of the users group to mount and unmount the
    ## cdrom as root


    4.一切ok,tansheng用户可以使用sudo命令了

    [root@localhost ~]# su - tansheng
    [tansheng@localhost ~]$ sudo service sshd status
    [sudo] password for tansheng: 
    openssh-daemon (pid  2390) 正在运行...
    [tansheng@localhost ~]$ 
  • 相关阅读:
    [BJOI2012]最多的方案(记忆化搜索)
    our happy ending(状压dp)
    [NOI2005]聪聪与可可(期望dp)
    CF983A Finite or not?(数学)
    [POI2012]STU-Well(二分答案+神仙操作)
    作诗2(玄学)
    IncDec Sequence(差分)
    [Vani有约会]雨天的尾巴(树上差分+线段树合并)
    合法括号序列(dp+组合数学)
    [SHOI2014]概率充电器(概率+换根dp)
  • 原文地址:https://www.cnblogs.com/ttss/p/4195455.html
Copyright © 2011-2022 走看看