備註:命令很簡單,重點在於不需要輸入密碼。可以結合自定義桌面圖標,一鍵執行腳本。
#!/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.