The shutdown on the cog-wheel checks if you are allowed to shutdown the machine. This is done via PolicyKit. In case of shutdown this statement in the file /usr/share/polkit-1/actions/org.freedesktop.consolekit.policy
is checked:
<action id="org.freedesktop.consolekit.system.stop">
<description>Stop the system</description>
<message>System policy prevents stopping the system</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
</action>
The PolicyKit triggers a dbus-send
command. In case of shutdown it would be:
dbus-send --system --print-reply --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown
There is a daemon running in the background with root-Privileges that invokes the shutdown command for you.
When you want to be able to shutdown the machine "the old way" via command line (shutdown, reboot, halt, ...
), then you need to add the suid-Bit to those commands. But be aware, everyone on your system, that has access to the shell could then shutdown your machine.
Best Answer
From Wikipedia:
Its a temporary one-time command with superuser (administrator) privileges without direct root login.