Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

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

The system refuses to shut down or reboot while another (GUI) session is open. It simply logs me out, when I select shut down or restart from the system menu.

How is that accomplished?

I am not asking for a rationale (it is quite clear that shutting down might have adverse impacts on the work of another user) but for the mechanism behind this behavior.

share|improve this question
up vote 3 down vote accepted

When you click the shutdown button (in Unity):

  1. The SessionView asks the SessionManager if the user is authorized to shutdown.

  2. The SessionManager uses systemd-logind to check /org/freedesktop/ConsoleKit/Manager for the authorization.

  3. ConsoleKit sets that property essentially by checking if multiple users are logged in. If multiple users are logged in, it denies authorization. In addition, depending on how the system has been set up, ConsoleKit may also use polkit or role-based access control to determine authorization.

  4. If SessionView does not receive authorization for the user to shutdown, it changes the action mode from shutdown to logout.

As an aside, note that this behavior (and how to implement it) is a decision made by Ubuntu. I had recently installed Arch with Gnome 3.8 to a partition, so logged in two users there to see how what happened when one of them shutdown. There was a message warning that other users were logged in and might lose work, but clicking OK let the shutdown continue.

[Edit based on OP comment]

The simplest way to change this behavior is to bypass it. In a terminal or a script, issue:

sudo shutdown -h 0 for immediate shutdown or sudo shutdown -r 0 for a restart.

This assumes the user who wants to shutdown has administrative privileges, but the user could also be granted admin privilege only for shutdown.

With a script you cold add in some of niceties like warning about other logged in users and allowing the user to change their mind about shutting down.

Someone else may have another idea (or could likely provide a fleshed-out script in response to a new question), but I can't think of anything easy (say, without recompiling a custom version of Unity) or safe beyond this solution.

share|improve this answer
Thank you for the findings and explanation - do you happen to have any idea where one could change that behavior? If it is more involved I'll ask another question, to keep things tidy. – guntbert Sep 11 '13 at 19:17

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.