我已经更改了关机命令,以便能够以普通用户(非 root)身份运行它:
sudo chmod a+s /sbin/shutdown
现在我只有在运行关机时才能回到 root 状态:
$ sudo chmod a-s /sbin/shutdown
$ ls -l /sbin/shutdown
lrwxrwxrwx 1 root root 14 May 5 20:55 /sbin/shutdown -> /bin/systemctl
$ ls -l /bin/systemctl
-rwxr-xr-x 1 root root 659848 May 5 20:55 /bin/systemctl