i want to give one user who is trusted to me this shutdown option for that i dont want to give our root user to him.
This can be done with Sudo:
- type "visudo" to edit /etc/sudoers,
- If not there add a line for your localhost: "Host_Alias LOCAL=localhostname" near the top of the file. "localhostname" is output from "hostname -s",
- Add the user if not already there: "User_Alias LUSER1=localusername". localusername is his local accountname,
- Add the command to shut down: "Cmnd_Alias SHUTDOWN=/sbin/shutdown -h now". Choose any arguments, but don't make the last one a wildcard unless you want him/her to type "shutdown -h now + 1 year" ;-p. If you need to allow him/her to add arguments but within a strict range and you don't want to use a regex and your scripting skills are OK, then you can replace the "/sbin/shutdown -h now" line with a wrapper script.
- Link command to user: "LUSER1 LOCAL=SHUTDOWN". He/she can now type "sudo /sbin/shutdown -h now" to bring down the box. You can also make an alias in his/her shell resource to make it easier:
alias sudo_shut="/location/of/sudo /sbin/shutdown -h now". This way he/she can type "sudo_shut" when logged in.
* If you fail making this work, or you don't understand this post your edited /etc/sudoers file.
To stop the Service squid after the 6:00 for our official restrictions.
This can be done manually with Sudo as well as a automated with a cronjob. To have squid stop automagically each day of the week at 18:00, add the next line to /etc/crontab: "00 18 * * */1 root /sbin/service squid stop".
|