Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

When I try to shutdown the computer from a command line or terminal I must have root privileges:

amy@amy:~$ shutdown now
shutdown: Need to be root


amy@amy:~$ halt
halt: Need to be root

but when shutting down using the graphical user interface, i.e. shutdown button, or the hardware shutdown button, I'm not asked for the password to do so... What does that shutdown for the interface?? and why it doesn't need the password or the root privileges?? thank you...

I'm using Ubuntu 11.04 Natty...

share|improve this question
because if an attacker has physical access to your computer, you've lost already. Attempting to prevent someone who is within arms reach of the box from doing almost anything is at best a delaying tactic and mostly causes more inconvinience for day-to-day users than it would for an attacker. Most Linux distros will give you a root prompt if spoken to sternly during bootup for exactly this reason. – Joseph Rogers Jan 8 at 12:03
up vote 30 down vote accepted

The hardware power button triggers an ACPI event that acpid (the ACPI daemon) notices and reacts to; in this case by shutting down the system, although you could have it do whatever you want. The ACPI daemon runs as root, so it has permission to shutdown the system. Desktop environments (e.g. gdm for Gnome) typically run as root as well, so I suspect they work the same way -- you don't have permission to shutdown the system, but you can tell gdm you want it shut down and it can do it on your behalf

share|improve this answer
is it secure?? 'you could have it do whatever you want.' – amyassin Aug 10 '11 at 17:52
To get acpid to do something different than it already does, you'd have to be root, so you'd already have permission to do insecure things. It is also possible to use MAC systems like SELinux to protect acpid, restricting the things they are allowed to do, even while they run as root. – Warren Young Aug 10 '11 at 18:00
@amyassin Well, to change what it does you need root privileges; a normal user can't tell it what to do. But acpid is configurable, it can run different scripts depending on the hardware events it sees (for example, I have acpid lock my computer when I hit the power button) – Michael Mrozek Aug 10 '11 at 18:00
@amyassen If someone has physical access to your machine then it's too late to worry about security -- if the power button doesn't trigger a graceful shutdown they can just pull the power cord and cause an ungraceful shutdown. – Shadur Aug 10 '11 at 20:23
Said 'malicious software' would have to get root ownership and SUID permissions in order to tell init to make with the shutdown -- and again, by the time it gets to that point you have bigger problems to worry about than a possible shutdown. – Shadur Aug 11 '11 at 7:11

Michael's answer correctly discusses system function when using the hardware power switch, but most desktop environments actually use dbus for this purpose rather than doing it themselves. For example, GNOME uses dbus's org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown when the shutdown button is clicked. When this is sent, dbus does some checks to determine whether the user sending the message is authorised to perform a shutdown, and if they are, it shuts down the system.

You can emulate this by using dbus-send. For example, to shut down your system using dbus, use something like this:

dbus-send --system --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown
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.