Shutdown Linux Server With Shutdown Account

Have you ever wondered why shutdown account exists on Linux server, especially under Red Hat Enterprise Linux distribution? The answer is quite simple – shutdown account can shutdown server. Here is how you can enable the shutdown account:

1) Login as a root user .

2) Setup password for the shutdown account:
# passwd shutdown

2) Add access to shutdown –h now via sudo:
# visudo
Put any one of following line in your sudo configuration file:
shutdown ALL=/sbin/shutdown –h now
shutdown localhost=/sbin/shutdown –h now

Note that localhost will only allow sudo from local terminal. For network based shutdown make sure you use ALL or an IP address or a domain name, for complete syntax refer sudo(8), and sudoers(5) command man page.

4) Save and close the file.

5) Change the shutdown shell:
# vi /etc/passwd
Replace existing shell entry (/sbin/shutdown) to
/usr/bin/sudo /sbin/shutdown –h now

Chang text from:
shutdown:x:6:0:shutdown:/sbin:/usr/bin/sudo /sbin/shutdown –h now

6) Close and save the file.

7) Test it by login into system with shutdown username and password.

8) Please, note down that sudo will prompt for password. If you wish to get rid of this issue use NOPASS option in sudo configuration file.

9) Alternatively, you can use the sudo command only to achieve the same effect. This simple hack ensures that ordinary user can shutdown system without touching other part of the system.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 5 comments so far... add one
CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig 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
5 comments… add one
  • judy kitces Apr 26, 2007 @ 16:33

    i tried implementing this and i got the following error messages when i tried logging in at the console with user shutdown:

    gdm_slave_session_start: Directory /sbin/.gnome2 does not exist
    gdm_auth_user_add: /sbin is not owned by uid 6.

    i am running RHE3. please advise! thanks!

  • 🐧 nixCraft Apr 26, 2007 @ 20:52

    This is for shell access, for GUI there is inbuilt facility to shutdown server/workstation.

  • Philippe Dec 26, 2009 @ 15:01

    Hi Vivek,
    Informative topic, thanks.

    Typo here:
    should read:

  • 🐧 nixCraft Dec 28, 2009 @ 14:40

    Thanks for the heads up!

  • goldenfox Jun 21, 2011 @ 9:17

    Hi Vivek,

    I tried it in CentOS 5.6 machine and I encountered this error:

    server sshd[3890]: User shutdown not allowed because shell /usr/bin/sudo /sbin/shutdown -h now does not exist

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum