zoukankan      html  css  js  c++  java
  • sudo执行命令允许教程

    1.说明

    在Ubuntu中我们可能经常使用sudo执行一些高权限命令;但在CentOS中默认是不允许普通用户sudo的,如同以下情型

    [ls@ls bin]$ sudo ifconfig
    [sudo] password for ls: 
    ls is not in the sudoers file.  This incident will be reported.              #其中的ls是我的用户名
    

    2.赋予ls用户sudo权限

    其中的命令都要以root执行

    2.1增加/etc/sudoers文件写权限

    chmod u+w /etc/sudoers
    

    2.2增加用户

    编缉/etc/sudoers文件,找到“root  ALL=(ALL)  ALL“行在其下依葫芦画瓢加一行即可

    2.3撤消/etc/sudoers文件写权限

    chmod -w /etc/sudoers
    

    2.4一步到位的方法

    如果你觉得以上的操作比较麻烦那可使用以下命令一步到位

    chmod u+w /etc/sudoers
    sed -i '91als    ALL=(ALL)    ALL' /etc/sudoers                     #将其中的ls改为自成己想要的用户即可
    chmod -w /etc/sudoers
    
  • 相关阅读:
    NIO简述
    函数式编程
    ReadWriterLock读写锁
    Semaphore工具类使用
    CyclicBarrier工具类使用
    CountDownLatch工具类使用
    创建VUE+Element-UI项目
    <slot>插板使用
    Spring面试题
    实现定时任务的几种方式
  • 原文地址:https://www.cnblogs.com/lsdb/p/6742880.html
Copyright © 2011-2022 走看看