Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have an Ubuntu 10.04 LTS Desktop PC with GNOME.

How can I fully disable the reboot/shutdown/suspend/hibernate functions in GNOME or even with root? So that the root gives out the "reboot" or "pm-suspend" command it doesn't do anything, and the machine goes on. How can I fully disable these basic "features"?

share|improve this question
    
I dunno? As a kiosk? you just remove shutdown and pm-suspend from /sbin/ and /bin/ –  Amith KK Jan 7 '12 at 13:04
    
Those files could be in cache, no? Removing them will permanently disallow the reboot/shutdown/suspend/hibernation function even in GNOME? –  LanceBaynes Jan 7 '12 at 13:13
    
Yes, it would probably do so @Lance Baynes –  Amith KK Jan 7 '12 at 13:16
add comment

3 Answers

up vote 6 down vote accepted

User access to these actions are controlled by polkit. In particular, they correspond to the following actions:

  • org.freedesktop.consolekit.system.stop
  • org.freedesktop.consolekit.system.restart
  • org.freedesktop.upower.suspend
  • org.freedesktop.upower.hibernate

All of these actions are allowed by default for active local users (although consolekit further restricts the first two permissions to only work when there is a single user logged into the system).

If you want to disable these actions create a file /etc/polkit-1/50-local.d/disable-shutdown.pkla containing something like:

[Disable shutdown/whatever]
Identity=unix-user:*
Action=org.freedesktop.consolekit.system.stop;org.freedesktop.consolekit.system.restart;org.freedesktop.upower.suspend;org.freedesktop.upower.hibernate
ResultAny=no
ResultInactive=no
ResultActive=no

This should prevent those actions from completing. More information on these policy files can be found by running man pklocalauthority.

If you are trying to restrict root though, this will only be a minor inconvenience. By definition, root is an unrestricted account according to the traditional UNIX discretionary access control system. If you can't trust users you've given full root access to, then you've got bigger problems than them just shutting down the system.

share|improve this answer
2  
Stopped working here with Ubuntu 13.10 !!! –  GabrieleV Jan 28 at 21:03
add comment
chmod -x /usr/sbin/pm-suspend
chmod -x /sbin/reboot
chmod -x /sbin/shutdown
share|improve this answer
2  
Can you substantiate your answer? I surely don't think he wanted to eliminate the possibilities of rebooting and shutting down. –  viyyer Jan 10 '12 at 3:43
    
How could one re-enable hibernation this way? –  Gabriel Fair Feb 5 '12 at 19:49
    
use "chmod +x" not "chmod -x" –  LanceBaynes Feb 6 '12 at 17:58
add comment

Consider installing molly-guard.

sudo apt-get install molly-guard

This package will prevent unintended shutdown/reboot/suspend/hibernate by interactively prompting you to enter the hostname of the system.

However, it's trivial to configure molly-guard to completely disable shutdown/reboot/suspend/hibernate. Simply create an executable file at /etc/molly-guard/run.d/99-prevent-all that has this in it:

#!/bin/sh
exit 1
share|improve this answer
    
This is a good solution for a multi-user computer where the administrator needs to do work and prevent all the other users from shutdown for a while. –  Alexis Wilke Jan 4 '13 at 5:51
add comment

Your Answer

 
discard

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.