检查是否已经安装sudo
[root@localhost ~]# ls -l `whereis sudo`
 ---s--x--x. 2 root root 186800 Sep  1  2010 /usr/bin/sudo
 -rw-r--r--. 2 root root  11296 Sep  1  2010 /usr/share/man/man8/sudo.8.gz
  若没安装,自行下载rpm或者源码进行安装
  增加配置 允许rhel 不输入密码就 sudo到root
 [root@localhost ~]# grep NOPASSWD /etc/sudoers
 # %wheel ALL=(ALL) NOPASSWD: ALL
 rhel  ALL=(ALL)       NOPASSWD: ALL
  验证:
 [root@localhost ~]# id
 uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
   [root@localhost ~]# su - rhel
 [rhel@localhost ~]$ id
 uid=500(rhel) gid=500(rhel) groups=500(rhel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
  [rhel@localhost ~]$ sudo -u root -s
 [root@localhost rhel]# id
 uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
    [root@localhost rhel]# sudo -l
 Matching Defaults entries for root on this host:
 requiretty, 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
   初略配置完毕!
   转载于:https://blog.51cto.com/6876163/1167020