How to shutdown computer under Linux?

January 29, 2013

You can't!

Maybe this sounds very ignorant, as you will immediately go and try it, or remember the last time you shut down it without problems. Well guys, today shutting down Linux powered desktop is a rocket science...

Let we see how it all started.

In the beginning we had shutdown -h now; people were happy, developers were happy. You knew exactly how it behaved: you (as ordinary user) had to be a super user or user with elevated privileges to call it; developers also had their method: check your id and simply system()that command.

The best of all, this was portable way even between BSD's, Solaris and (presumably) other Unix flavors popular in that time.

But, someone at some point decided this approach is too complicated, so not cool and so stone aged and decided to give ordinary user privileges to put down the computer without asking password. Who was it, I don't know; most likely thoseguys with idea that mouse and keyboard with a single button are enough for all your problems...

And we got HAL(Hardware Abstraction Layer); resemblance with more famous HALis probably just coincident, but both had one thing in common: they started as cool thing and ended up as pretty uncool crap.

So, our Linux HAL was also cool: DBus powered, supported all sort of things like receiving events for newly plugged in or off devices, restarting and shutting down computer, giving user privileges and so on.

It was so cool that distros started to ship it and we (users and developers) thought we had a golden egg: no more /procparsing, no more ask-a-password-to-restart and so on...

But, those guys decided it was (again) too complicated; if you see all sort of things it supported, even on portable way, it wascomplicated; just they needed time to figure it out. So we got a bunch of *Kit stuff: ConsoleKit, DeviceKit...

If you ever had any touch with API from Apple, you will notice *Kit naming inspiration origin... Doesn't this sounds too biased? Now, if I'm going to add some of LPCTSTR-ed HWORD-like call (MS Windows lowlevel API) over standard Linux calls, people will probably call me nuts because Windows API is a big NO NO; and it happens to be not cool.

Like somene on Slashdot said once: if they like Apple so much, why don't they simple develop apps for it, instead ruining Linux desktop? Sure, they would like it, but Apple would not a give a fuck about their 'cool ideas': those guys are serious and they know you don't wanna fuck with user who pays you a bunch of $$$ for your OS, hardware and devices.

Let we back to our beloved Linux: again, desktop evolved and they decided those *Kit stuff is deprecated (whatever it means today) and we got UPower (for 'power' support and all things they considers had to do with powering your computer), 'policy' and 'console' went to systemd and I'm not sure what crap they think again; but don't be fooled: shutting down or restarting your computer has nothing to do with 'power' so UPower only support suspending and hibernating your PC.

standards

Now, if you are developer and you just want to restart or shutdown your computer, you have 4 (yes four) different way to do it and all depends on distribution: on Fedora you can still use ConsoleKit (although it has systemd); Slackware does not come with systemd and has ConsoleKit by default up, but you have to manualy start UPower, Arch recenlydeprecated ConsoleKit in favor of systemd-logind...

Are you getting confused?

But, on other more serious OS-es like FreeBSD, developers don't have time to think about Kits, systemd and all that crap someone came up during toilet session; they are, from Linux developer perspective, stuck on stone age: they are still using HAL.

Sure, those guys are serious and have much better things to do, like improving SMP support, adding support for new hardware, fixing freaking bugs in kernel and userland apps instead of thinking the way how to power of your machine.

One famous Gnome developer said how Linux desktop is dead: yes, guys like him messed things up and flew away saying how nothing could be done... Linux desktop is slowly becoming a corporation led by small number of developers with influence and powerful companies, where even a single damn thing like turning of computer was made so complicated you wish to puke.

Do you know what is the main irony? Solaris, AIX, BSD's in some features are more portable than Linux distros. Go figure out why.