无需进入登录 shell 即可注销

无需进入登录 shell 即可注销

在 Ubuntu 桌面中,有一个命令立即注销,并且用户无需进入登录 shell 即可执行该命令:

 $ gnome-session-quit --logout --no-prompt

问:如果有的话,Ubuntu Server 中的等效命令是什么?

(我知道logout在非登录 shell 中不允许,但也许有一个不同的命令。首选解决方案是正常注销,而不是例如杀死守护进程。)

答案1

pkill或者skill似乎是答案:

$ bash
$ bash
$ pkill -KILL -u $USER

Ubuntu 11.10 mach1 tty1

mach1 login: _

来自skill 手册页,可以使用其他退出信号代替-KILL

   Name     Num   Action    Description

   ALRM      14   exit
   HUP        1   exit
   INT        2   exit
   KILL       9   exit      this signal may not be blocked
   PIPE      13   exit
   POLL           exit
   PROF           exit
   TERM      15   exit
   USR1           exit

   USR2           exit
   VTALRM         exit
   STKFLT         exit      may not be implemented

相关内容