Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How do I allow normal users to shutdown/reboot?

I try to shutdown as my user el but get this response:

el@voyager ~ $ shutdown now
shutdown: you must be root to do that!
Usage:    shutdown [-akrhPHfFnc] [-t sec] time [warning message]
              -a:      use /etc/shutdown.allow
              -k:      don't really shutdown, only warn.
              -r:      reboot after shutdown.
              -h:      halt after shutdown.
              -P:      halt action is to turn off power.
              -H:      halt action is to just halt.
              -f:      do a 'fast' reboot (skip fsck).
              -F:      Force fsck on reboot.
              -n:      do not go through "init" but go down real fast.
              -c:      cancel a running shutdown.
              -t secs: delay between warning and kill signal.
              ** the "time" argument is mandatory! (try "now") **

I want to have my user el be able to shutdown the computer, what is the best way to do that?

share|improve this question

1 Answer 1

How to allow normal users to shutdown/reboot in gentoo:

If you get any of these kinds of errors:

shutdown: you must be root to do that!
poweroff: must be superuser.
reboot: must be superuser.
halt: must be superuser.

One way to grant users access to superuser only commands to use the sudo command:

  1. Login as root:

    su -
    
  2. Emerge Sudo:

    emerge app-admin/sudo
    
  3. Run visudo:

    visudo
    
  4. Configure visudo:

    Enter the following into visudo

    # Replace YourUserName with your user name.
    YourUserName  ALL=(root) NOPASSWD: /sbin/reboot
    YourUserName  ALL=(root) NOPASSWD: /sbin/halt
    YourUserName  ALL=(root) NOPASSWD: /sbin/poweroff
    YourUserName  ALL=(root) NOPASSWD: /sbin/shutdown
    
  5. Save visudo file, and exit to normal user access.

  6. From user level console, run this command:

    el@voyager ~ $ sudo shutdown now
    
    Broadcast message from root@voyager (pts/0) (Sat Sep 21 18:19:56 2013):
    
    The system is going down to maintenance mode NOW!
    el@voyager ~ $ 
    
  7. You may notice that maintenance mode still leaves the fans and power on, yet still gentoo is not running. You must use the -h flag on shutdown which means halt, Otherwise you're only dropping down into single/maintenance mode. Consider using 'poweroff' instead.

    el@voyager ~ $ sudo halt
    
    Broadcast message from root@voyager (pts/0) (Sat Sep 21 18:26:12 2013):
    
    The system is going down for system halt NOW!
    

The operating system, fans and power are now turned off by the user.

share|improve this answer
    
halt is also meant to leave the power on, so poweroff is the correct command to use (even though simpler init systems treat them as synonyms). –  grawity Sep 21 '13 at 14:40
    
su - does the same thing as su - root—that is, it switches to root. Not su. There isn't a user called su by default (though you could make one…) –  Blacklight Shining Sep 23 '13 at 3:01

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.