LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   normal user running shutdown (https://www.linuxquestions.org/questions/slackware-14/normal-user-running-shutdown-127655/)

cblamer 12-20-2003 05:13 PM

normal user running shutdown
 
if possible looking for a way to have a normal user be able to run shutdown, and reboot commands. Now since i am root, and user, and the only user i could just use su or something the do the commands if that the easiest way.

any help would be great
thanks
chris

Kristijan 12-20-2003 06:39 PM

man sudo

and take a read of that, if your still stuck, just post back.

cblamer 12-21-2003 01:55 AM

ok thanks, figured it out

so if i am doing this right, i would be typing "su /sbin/shutdown -h now"?
if that correct then another question, can i create a script called say "killpc" in pc home bin dir that contains that command line, that would make less typing?

im thinking it woud work but what do i know?

chris

core 12-21-2003 04:56 AM

No, using su, it would be su -c "/sbin/shutdown -h now"
But you can just press CTRL+ALT+DEL to reboot :)
And sudo is not su. with sudo you can specify a user and a given program that the user can run as root wiithout entering a password..


f.e. as root
visudo
then find the line where is:
# User privilege specification
root ALL=(ALL) ALL

And below that you can add your entry... f.e. allowing user foobar to execute shutdown without passwd:
foobar ALL=NOPASSWD:/sbin/shutdown



now foobar can just enter "sudo /sbin/shutdown -h now" and he must not enter a passwd..
for lazyness, you could add an alias to your .bashrc or .bash_login, say
alias shutdown='sudo /sbin/shutdown -h now'
re-login and 'shutdown'

cblamer 12-21-2003 05:15 AM

actualy when i wrote that it was supposed to be a sudo, not su. guess thats what i get for not proofreading eh? :D

thanks though extermely helpful
chris

minio 12-21-2003 06:57 AM

I find out other way how to do this. You need a "pam" package and "usermode" package, both you can download from dropline http://sourceforge.net/project/showf...group_id=62166 . Install them and you will be able use halt and reboot as user. If you really need shutdown command then do "ln -s consolehelper shutdown", "cp /etc/pam.d/halt /etc/pam.d/shutdown" and "cp /etc/security/console.apps/halt /etc/security/console.apps/shutdown". Then as a user you can try to type "shutdown -h now" :)

Kristijan 12-21-2003 08:44 PM

As for the killpc, you could try make an alias in you ~/.bashrc

(eg: your ~/.bashrc file)

Code:

alias killpc='sudo shutdown -h now'
If you dont have a ~/.bashrc just create one.

Save that in ~/.bashrc, and exit to your CLI

Then just

Code:

source ~/.bashrc
And give it a test run :)


All times are GMT -5. The time now is 08:41 AM.