How to: Allow Any User To Shutdown a Linux Server

You need to use the sudo command to grant a permission to other users to shutdown your server. The sudo command allows a permitted user to execute a command as the superuser or another user, as specified in the /etc/sudoers file. Login as a root user and type the visudo command to edit the sudoers file.

Use Configuration

In this example, allow user rocky to shutdown computer (first login as a root user):
$ su -
# visudo

Append the following configuration to a file:
rocky /sbin/reboot
Save file and close the file. Now, rocky user can halt server by typing the following command:
$ sudo /sbin/halt


Please note that at password prompt rocky need to type his own password.

Another option is add users to /etc/shutdown.allow access control file. shutdown command can see if an authorized user is logged in on one of the virtual consoles. If shutdown command is called with the -a argument , it checks to see if the file /etc/shutdown.allow is present. It then compares the login names in that file with the list of people that are logged in on a virtual console only if one of those authorized users or root is logged in, it will proceed. Otherwise, it will write the message

shutdown: no authorized users logged in

First login as a root user:
# echo rocky >> /etc/shutdown.allow
Alternatively, use a text editor such as vi to add a username to etc/shutdown.allow file (max 32 names are allowed at a time):
# vi /etc/shutdown.allow
Finally, rocky can login and type the following command:
rocky@server1 $ /sbin/shutdown -a -h 0

See also:

🐧 Please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
10 comments… add one
  • benjamin rualthanzauva Sep 8, 2013 @ 16:46

    Looks this topics needs a revisit todat. My distro (SL 6.4) has user verion of poweroff, halt, reboot provide by usermode package. I can shutdown, reboot as a normal user (from the command line as well)

    $ which {poweroff,reboot,halt}
    rpm -qf $(which poweroff reboot halt)

    As root

    # which {poweroff,reboot,halt}

    # rpm -qf $(which poweroff reboot halt)

  • mclien Jun 4, 2012 @ 9:03

    at least in debian systems the shutdoen.allow only works for the alt+ctrl+del way of it.
    still the user isn’t allowed to invoke /sbin/shutdown…

  • Parag Jul 29, 2010 @ 4:26

    That’s great info. It works and thanks a lot.

  • 🐧 nixCraft Dec 28, 2009 @ 17:47

    I’m embarrassed to say that it took me forever to realize a typo 🙁

  • Philippe Dec 28, 2009 @ 17:20

    Well I share the easy part.

    But again,
    You still mispelled it – that’s r-o-c-k-y
    not r-o—k—c—-y

    breeze deeply. ;-))

  • 🐧 nixCraft Dec 28, 2009 @ 17:15

    My bad 🙁

  • Philippe Dec 28, 2009 @ 16:50

    Yep – but then you typed it too quickly

    echo”rokcy” >> /etc/shutdown.allow

    should read

    echo “rocky” >> /etc/shutdown.allow

    and by the way, these quotes are useless here. I’ve never seen a user login that would require quoting, BTW.

    echo rocky >> /etc/shutdown.allow

  • 🐧 nixCraft Dec 28, 2009 @ 14:53

    Once again thanks for pointing it out 🙂

  • Philippe Dec 26, 2009 @ 15:11

    Nice topic.

    But in :
    # touch /etc/shutdown.allow
    # echo”username” >> /etc/shutdown.allow

    The first line is useless. (touch)

  • we3cares Sep 15, 2008 @ 4:15

    Very Great Article….. Like it so Much..

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Problem posting comment? Email me @