以root用户登录 adduser down passwd down #vi /etc/sudoers //添加下面一行 down ALL=NOPASSWD: /sbin/shutdown -h now 然后修改/etc/profile
if [ $LOGNAME = "down" ] //如果用户名称为down then echo “The machine will shutdown now! please logout!" //显示信息 sleep 5 /usr/bin/sudo /sbin/shutdown -h now //关机命令 exit fi