Pedro's blog: db2, mysql, php, linux and performance

Halt permission on Linux
11/12/2009, 14:58
Filed under: General,GNU/Linux,Security | Tags: , , ,

Hey folks!

I had to give halt and reboot permissions to a linux user, let’s talk about it:

Login as root and:


this will open the file /etc/sudoers, then add the following next lines:

%users YOURHOSTHERE = /sbin/halt, /sbin/reboot

And if you don’t want to have to type a password each time then use this line:

%users YOURHOSTHERE = NOPASSWD: /sbin/halt, /sbin/reboot

Save and close the file.

By now, every user in the users group (/etc/group )  is able to run halt and reboot commands:

#sudo /sbin/halt

#sudo /sbin/reboot

If you don’t want to type the sudo command every time, then add this lines to the ~/.bash_profile of every user:

alias halt=’sudo /sbin/halt’
alias reboot=’sudo /sbin/reboot’