Super User is a question and answer site for computer enthusiasts and power users. 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

My dirty solution is to chmod +s /sbin/shutdown. It works but this is probably not good practice and insecure. Moreover after some system updates the suid bit gets reset. What would be the correct way to do it?

share|improve this question
    
i usually do sudo shutdown now -h – kobaltz Jul 8 '12 at 20:12
up vote 3 down vote accepted

All users? Or a selected subset of them? Will they use the computer locally or also remotely (e.g. via ssh).

In case of a few users who also work remotely sudo will work fine. See this link for details.

If they are logging in locally and via a GUI then there are better options. E.g. capturing the three finger salute via init and letting that trigger a 1 minute delayed shutdown. It has been ages since I set that up though, so I skipping on the details for that. (I used that back when Slackware 3 was modern)

share|improve this answer
    
Either a single user or a group such as %users. The idea is to avoid using sudo every time and entering passwords. According to the link you posted a line in sudoers like %users ALL=NOPASSWD:/sbin/shutdown is probably all I need. Thank you! – ccpizza Jul 8 '12 at 20:27

If your shutdown accepts the -a switch (check with shutdown --help), you can do the following:

  • Add the users that should be able to shut the system down to /etc/shutdown.allow.

    Example:

    userA
    userB
    
  • Shut the system down using the -a switch.

    Example:

    shutdown -a -h now
    

Source: UNIX man pages : shutdown (8)

share|improve this answer
    
looks like my version of shutdown (generic Linux of the -buntu family) does not support the -a option. Looks like the expected way is to create a %shutdown group which would include the users who need to shutdown and then reference that in the sudoers file. – ccpizza Jul 8 '12 at 20:32

I use SL 6.4. It has user version of poweroff, halt, reboot provided by usermode package. I can shutdown, reboot as a normal user (from the command line as well)

    $ which {poweroff,reboot,halt}
    /usr/bin/poweroff
    /usr/bin/reboot
    /usr/bin/halt

    rpm -qf $(which poweroff reboot halt)
    usermode-1.102-3.el6.x86_64
    usermode-1.102-3.el6.x86_64
    usermode-1.102-3.el6.x86_64

As root

    # which {poweroff,reboot,halt}
    /sbin/poweroff
    /sbin/reboot
    /sbin/halt

    # rpm -qf $(which poweroff reboot halt)
    upstart-0.6.5-12.el6.x86_64
    upstart-0.6.5-12.el6.x86_64
    upstart-0.6.5-12.el6.x86_64
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .