zoukankan      html  css  js  c++  java
  • Linux下不同用户对应不同权限

    Host Aliases 主机别名

    User Aliases 用户别名

    Networking 网络操作

    route/ifconfig/ping/dhclient/net/iptables/rfcomm/wvdial/iwconfig/mii-tool

    软件安装

    rpm、up2date、yum

    服务命令

    service,chkconfig,systemctl start,systemctl stop,systemctl reload, systemctl restart, systemctl status, systemctl enable, systemctl disable

    本地数据升级命令

    updatedb

    磁盘操作相关命令

    fdisk,sfdisk, parted, partprobe, mount, umount

    代理权限命令

    visudo,chown,chmod,chgrp

    进程命令

    nice,kill,killall

    驱动命令

    modprobe

     

     

     

    实例1:让普通用户fieldyang具有/etc/init.d/nagios脚本重启的权限,可以在/etc/sudoers添加如下设置:

    [root@test ~]# visudo

    fieldyang ALL=NOPASSWD:/etc/init.d/nagios restart

     

    实例2:让普通用户fieldyang具有所有超级用户的权限而又不用输入密码

    [root@test ~]# visudo

    fieldyang ALL=(ALL)NOPASSWD:ALL

    [fieldyang@test ~]#sudo su -

    [fieldyang@test ~]#pwd /root

     

    实例3:

    针对MySQL数据库的设置,让test组中的test用户具备/etc/init.d/mysqld的权限

    ######################## mysql ################

    1.

    [root@test ~]# groupadd test

    [root@test ~]# useradd -g test -m -d /home/test -s /bin/bash test

    [root@test ~]# passwd test

    2.

    [root@test ~]# visudo

    # test ALL=(ALL) NOPASSWD: /etc/init.d/mysqld

    test ALL=(ALL) /etc/init.d/mysqld

    3. start/stop mysql

      3.1) start mysql

      login test

    [root@test ~]# su test

    [test@test ~]$ sudo /etc/init.d/mysqld start

      3.2) stop mysql

      login test

    [root@test ~]# su test

    [test@test ~]$ sudo /etc/init.d/mysqld stop

    实例4:针对tomcat的设置,让test组中的test用户具备tomcat操作的权限

    ######################## tomcat ################

    1.

    [root@test ~]# groupadd test

    [root@test ~]# useradd -g test -m -d /home/test -s /bin/bash test

    [root@test ~]# passwd test

    2.

    [root@test ~]# visudo # test ALL=(ALL)

      /usr/local/tomcat/bin/shutdown.sh,/usr/local/tomcat/bin/startup.sh

      test ALL=(ALL) NOPASSWD: /usr/local/tomcat/bin/shutdown.sh,/usr/local/tomcat/bin/startup.sh

    3.

    [root@test ~]# vim /usr/local/tomcat/bin/catalina.sh

    ### JDK

      export JAVA_HOME=/usr/local/jdk

      export JRE_HOME=$JAVA_HOME/jre

      4. start/stop tomcat

      4.1) start tomcat

      login test

    [root@test ~]# su test

    [test@test ~]$ sudo /usr/local/tomcat/bin/startup.sh

    [test@test ~]$ ss -ntlup | grep java

    [test@test ~]$ curl -I http://localhost:8080

    4.2) stop tomcat

      login test

    [root@test ~]# su test

    [test@test ~]$ sudo /usr/local/tomcat/bin/shutdown.sh

     

     

    sudo 切换超级用户和普通用户不需要输入密码

    visudo
    
    在 root ALL=(ALL) ALL 下面输入自己的账号
    
    去掉注释 110行左右
    %wheel ALL=(ALL) NOPASSWD: ALL
    :wq
    添加自己的用户打wheel组中
    gpasswd -a zhoujt wheel
    最后执行以下命令已确认登录时不在输入密码了
    sudo date
    
    验证:
    [root@localhost ~]# su zhou
    [zhou@localhost root]$ sudo su - zhou
    上一次登录:二 9月 15 16:54:16 CST 2020pts/0 上
    [zhou@localhost ~]$ sudo su - root
    上一次登录:二 9月 15 16:51:32 CST 2020pts/0 上
    [root@localhost ~]# whoami && pwd
    root
    /root
    [root@localhost ~]# 
     

     

  • 相关阅读:
    《Head First 设计模式》 第八、九章 模板方法模式、迭代器模式、组合模式
    《Head First 设计模式》 第十、十一章 状态模式、代理模式
    《Head First 设计模式》 第六、七章 命令模式、适配器模式、外观模式
    《Head First 设计模式》 第四、五章 工厂模式、单例模式
    敏捷软件开发 第十章、第十一章、第十二章
    《Head First 设计模式》 第二、三章 观察者模式、装饰者模式
    二叉树-面试题27-二叉树的镜像
    堆栈-155-最小栈
    堆栈-20-有效括号
    java编程基础(六)----泛型
  • 原文地址:https://www.cnblogs.com/security-guard/p/13808691.html
Copyright © 2011-2022 走看看