本篇文章給大家分享的是有關(guān)如何進(jìn)行l(wèi)inux sudo權(quán)限配置,小編覺(jué)得挺實(shí)用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說(shuō),跟著小編一起來(lái)看看吧。
創(chuàng)新互聯(lián)建站主要從事做網(wǎng)站、網(wǎng)站制作、網(wǎng)頁(yè)設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)西夏,十年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來(lái)電咨詢建站服務(wù):18982081108
這里記錄一下linux的sudo簡(jiǎn)單配置過(guò)程,備后查。
1、root打開(kāi)sudo配置文件
[root@centos ~]# visudo
2、sudo配置項(xiàng)
## 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用戶執(zhí)行的所有命令
3、配置mysql免密執(zhí)行
## 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部設(shè)置的mysql操作系統(tǒng)層的密碼
-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用戶測(cè)試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配置完成!
以上就是如何進(jìn)行l(wèi)inux sudo權(quán)限配置,小編相信有部分知識(shí)點(diǎn)可能是我們?nèi)粘9ぷ鲿?huì)見(jiàn)到或用到的。希望你能通過(guò)這篇文章學(xué)到更多知識(shí)。更多詳情敬請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。