About nixCraft

Topics

How to: Allow any users to Shutdown Linux server

Posted by Vivek Gite [Last updated: September 13, 2007]

You need to use sudo command to grant a permission to other users to shutdown your server. sudo 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 visudo command to edit the sudoers file:

Allow any user to shutdown my Linux server

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

Append following text to file:
rocky server.mydomain.com=/sbin/halt /sbin/reboot
Save file and exit to shell prompt. Now rocky can halt server by typing command:
$ sudo /sbin/halt
Output:

Password:

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

Another way is to allow other users to shutdown server is to add them to /etc/shutdown.allow access control file. shutdown command can check to 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:
# touch /etc/shutdown.allow
# echo"username" >> /etc/shutdown.allow

On the other hand, use text editor such as vi to add username (Max 32 names are allowed):
# vi /etc/shutdown.allow
Shutdown computer using following command:
$ /sbin/shutdown -a -h 0

See also:

Tell us how we're doing: Please answer a few questions about your experience to help us improve nixCraft.

You may also be interested in other helpful articles:

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>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Tags: , , , , ,

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