未安装报错
[xy@archlinux ~]$ sudo -s
-bash: sudo: command not found
安装
[xy@archlinux ~]$ su -
Password:
[root@archlinux ~]# pacman -S sudo
resolving dependencies…
looking for conflicting packages…
Packages (1) sudo-1.9.7.p2-1
Total Download Size: 1.51 MiB
Total Installed Size: 6.52 MiB
:: Proceed with installation? [Y/n] y
…
无权限报错
[root@archlinux ~]# su - xy
[xy@archlinux ~]$ sudo -s
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for xy:
xy is not in the sudoers file. This incident will be reported.
配置权限
[xy@archlinux ~]$ su
[root@archlinux ~]# vi /etc/sudoers.d/xy.conf
xy ALL=(ALL) ALL
还是一样的报错
[xy@archlinux ~]$ sudo -s
[sudo] password for xy:
xy is not in the sudoers file. This incident will be reported.
问题解决:
[root@archlinux ~]# cd /etc/sudoers.d
[root@archlinux sudoers.d]# mv xy.conf 01_xy
[xy@archlinux ~]$ sudo -s
[sudo] password for xy:
[root@archlinux xy]#
小结:
/etc/sudoers.d下面的文件格式 mn_somename 其中mn弄成数字。
无密码切换
[root@archlinux ~]# vim /etc/sudoers.d/01_xy
xy ALL=(ALL) NOPASSWD: ALL