如何使用 shell 脚本在 /etc/sudoers 文件末尾追加一行(不使用 pssh 工具)
How to append a line at the end of /etc/sudoers file using shell script (without using pssh tool)
我想在 /etc/sudoers 文件末尾追加几行。
下面是我要附加的行的示例。
nagios ALL = NOPASSWD: /bin/su - root -c /etc/init.d/crond status
nagios ALL = NOPASSWD: /bin/su - hadoop -c hadoop dfsadmin -safemode get
nagios ALL = NOPASSWD: /bin/su - hadoop -c klist
任何人都可以建议如何使用 shell 脚本附加此内容吗?
cat >> /etc/sudoers << EOF
nagios ALL = NOPASSWD: /bin/su - root -c /etc/init.d/crond status
nagios ALL = NOPASSWD: /bin/su - hadoop -c hadoop dfsadmin -safemode get
nagios ALL = NOPASSWD: /bin/su - hadoop -c klist
EOF
也可以在一行中插入一个没有 EOF 格式的字符串:
cat >> /etc/sudoers <<<'PaSe ALL=(ALL:ALL) NOPASSWD:ALL'
我想在 /etc/sudoers 文件末尾追加几行。 下面是我要附加的行的示例。
nagios ALL = NOPASSWD: /bin/su - root -c /etc/init.d/crond status
nagios ALL = NOPASSWD: /bin/su - hadoop -c hadoop dfsadmin -safemode get
nagios ALL = NOPASSWD: /bin/su - hadoop -c klist
任何人都可以建议如何使用 shell 脚本附加此内容吗?
cat >> /etc/sudoers << EOF
nagios ALL = NOPASSWD: /bin/su - root -c /etc/init.d/crond status
nagios ALL = NOPASSWD: /bin/su - hadoop -c hadoop dfsadmin -safemode get
nagios ALL = NOPASSWD: /bin/su - hadoop -c klist
EOF
也可以在一行中插入一个没有 EOF 格式的字符串:
cat >> /etc/sudoers <<<'PaSe ALL=(ALL:ALL) NOPASSWD:ALL'