Ubuntu – logout without being at login shell

bashUbuntuubuntu server

In Ubuntu Desktop, there's a command to logout immediately, and the user can execute it without being at the login shell:

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

Q. What is the equivalent command in Ubuntu Server, if any?

(I'm aware that logout at a non-login shell is not allowed, but perhaps there's a different command. The preferred solution logs out gracefully instead of e.g., killing daemons.)

Best Answer

pkill or skill seem to be the answer:

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

Ubuntu 11.10 mach1 tty1

mach1 login: _

From the skill manpage, other exit-signals can be used instead of -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