Thursday, June 1, 2006

shutdown using non-root

How to enable a non-root user to shuwdown a linux system

First, you need a non-root user, go and create it using root account

[root@deniro ver]# useradd -d /home/vertito vertito -s /bin/bash && passwd vertito

This would create a new bash-enabled user prompting you for a new password.

You then edit /etc/sudoers file by launching your favorite editor like so

[root@deniro ver]# nano -w /etc/sudoers

or simply

[root@deniro ver]# visudo

and inserting

SHUTDOWN localhost=/sbin/shutdown -h now

and save.

Logout as root and login as user vertito. User vertito was the last user created a while ago.

[vertito@deniro ~]$ /sbin/shutdown -h now

Just make sure /sbin/shutdown is world readable and executable as mine is not! !

Further readings:
man sudo
man shutdown
man sudoers

sources: WWW

application: dont reboot, shut it down, makes work simple!


Sign up for PayPal and start accepting credit card payments instantly.
ILoveTux - howtos and news | About | Contact | TOS | Policy