您好,登錄后才能下訂單哦!
本篇文章給大家分享的是有關如何進行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配置完成!
以上就是如何進行linux sudo權限配置,小編相信有部分知識點可能是我們日常工作會見到或用到的。希望你能通過這篇文章學到更多知識。更多詳情敬請關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。