Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.)

share|improve this question
When you say logout, do you mean you want to terminate the shell invoked at login, plus any child processes of that shell, regardless of the process you happen to be in at the moment? So for example, if you were five bash shells down you want to issue a logout that will terminate the login shell, and as a result kill all the child shells and any processes they may have spawned? – Paul Dec 15 '11 at 2:39
Note that your statement that exit doesn't work in a non-login shell is incorrect, it is logout that doesn't work. It isn't forbidden, it just doesn't make sense to logout if you aren't in a login shell. – Paul Dec 15 '11 at 2:42
@Paul, Ah, my mistake...thanks. Yes, I do mean terminate login shell plus its children. I fixed the question. If the user isn't allowed to use the logout command (regardless of whether it makes sense), wouldn't the command be considered "forbidden"? – tony19 Dec 15 '11 at 4:37
Well I would say that "forbidden" is something you don't rights or permission to do. Rather than something that doesn't make sense to do. Like the difference between being not permitted to issue a command to shutdown a webserver (forbidden), versus trying to issue the same command where no webserver is running (no sense :)) – Paul Dec 15 '11 at 4:52
@Paul, Ok, I'm with you now. :) – tony19 Dec 15 '11 at 5:01
up vote 1 down vote accepted

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
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.