Sudo
跳到导航
跳到搜索
sudo
echo 'evan ALL=(ALL) ALL' >>/etc/sudoers.d/evan sudo -i 再用evan的密码就行了 如果是不要密码 echo 'evan ALL=(ALL) NOPASSWD:NOPASSWD:ALL' >/etc/sudoers.d/evan 普通用户给sudo 执行特殊命令 mysql ALL=(ALL) NOPASSWD: /bin/whoami xtx ALL=(ALL) NOPASSWD: /usr/bin/date
shooting
# sudo apache ls sudo: /etc/sudo.conf is owned by uid 900, should be 0 sudo: /etc/sudo.conf is owned by uid 900, should be 0 sudo: /etc/sudoers.d 属于用户 ID 900,应为 0 sudo: apache:找不到命令 # ll /etc/sudoers.d/ 总用量 8 -rw-r--r-- 1 root root 39 2月 18 16:59 apache -r--------. 1 www www 61 8月 11 2021 cfroot [root@idc-test-all-php-192-168-10-122-c7 /etc/supervisord.d] {17:01:17} (0) # ll /etc/sudo.conf -rw-r-----. 1 www www 1786 9月 30 2020 /etc/sudo.conf chown root.root /etc/sudo.conf chown -R root:root /etc/sudoers.d #我只执行了上面两个 chmod u=rwx,g=rx,o=rx /etc/sudoers.d/ chmod u=r,g=r,o= /etc/sudoers.d/*
参考
如何成为 Root 用户 https://wiki.centos.org/zh/TipsAndTricks/BecomingRoot
CentOS 系统sudo命令配置 http://towangwang.blog.51cto.com/17151/936708