linux sudo权限配置

    这里记录一下linux的sudo简单配置过程,备后查。

    1、root打开sudo配置文件

[root@centos ~]# visudo

    2、sudo配置项

## Next comes the main part: which users can run what software on

## which machines (the sudoers file can be shared between multiple

## systems).

## 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

mysql   ALL=(ALL)       ALL  #配置mysql用户等同root用户执行的所有命令

    3、配置mysql免密执行

## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment)

#includedir /etc/sudoers.d

mysql localhost=(root) NOPASSWD:ALL

    4、root修改mysql的密码

[root@centos ~]# passwd mysql

    5、mysql添加mysql用户的sudo密码,sudo密码是第4部设置的mysql操作系统层的密码

-bash-4.1$ sudo uname

[sudo] password for mysql: 

Linux

-bash-4.1$

    6、查看sudo配置

[root@centos ~]# sudo -l

Matching Defaults entries for root on this host:

    requiretty, !visiblepw, always_set_home, env_reset, env_keep="COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS",

    env_keep+="MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE", env_keep+="LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT

    LC_MESSAGES", env_keep+="LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE", env_keep+="LC_TIME LC_ALL LANGUAGE LINGUAS

    _XKB_CHARSET XAUTHORITY", secure_path=/sbin\:/bin\:/usr/sbin\:/usr/bin

User root may run the following commands on this host:

    (ALL) ALL

[root@centos ~]# 

     7、mysql用户测试sudo是否正确

-bash-4.1$ sudo mkdir /test1

-bash-4.1$ ls -l /test1

total 0

-bash-4.1$ rm -rf /test1

rm: cannot remove `/test1': Permission denied

-bash-4.1$ sudo rm -rf /test1

-bash-4.1$ ls -l /test1

ls: cannot access /test1: No such file or directory

-bash-4.1$ 

    linux的sudo配置完成!


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29357786/viewspace-2199488/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29357786/viewspace-2199488/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值