备注:命令很简单,重点在于不需要输入密码。可以结合自定义桌面图标,一键执行脚本。


#!/bin/bash
PASSWORD=
echo $PASSWORD  | sudo -S shutdown -h $1


man sudo

-S          The -S (stdin) option causes sudo to read the password from
            the standard input instead of the terminal device.  The pass‐
            word must be followed by a newline character.