jump to navigation

Allow any user to shutdown my Linux server December 15, 2009

Posted by jbanju in LINUX CentOS.

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


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



No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: