About nixCraft

Topics

Shutdown account to shutdown Linux server

Posted by Vivek Gite [Last updated: August 16, 2007]

Have you ever wondered why shutdown account exists on Linux server (especially in Red Hat Linux distribution)?

The answer is quite simple - shutdown account can shutdown server. Here is the simple procedure to use shutdown account to halt Linux server:

1) Setup password for shutdown account:
# passwd shutdown

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

Note that localhost will only allow sudo from local terminal. If you want network based shutdown then make sure you use ALL or IP or Domain name, for complete syntax read man page of sudo.

3) Save and exit to shell prompt

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

For example
Chang Text From:
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
To:
shutdown:x:6:0:shutdown:/sbin:/usr/bin/sudo /sbin/shutdown –h now

5) Close and Save the file

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

7) 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.

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

E-mail this to a Friend    Printable Version

You may also be interested in other helpful articles:

Discussion on This Article:

  1. judy kitces Says:

    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!

  2. vivek Says:

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

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Tags: , , , , , , , ,

Copyright © 2004-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Powered by Open source software.