LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-05-2011, 01:49 PM   #1
gujedan
Member
 
Registered: Oct 2010
Posts: 121

Rep: Reputation: 1
halt & reboot commands without root


how can I execute halt/reboot in a shell script without running it as root? the default shutdown/restart scripts in init.d do it, but I can't understand how.
 
Old 11-05-2011, 01:54 PM   #2
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,699
Blog Entries: 23

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
One immediate thought that pops in mind is to set up a group, add the non-privved user to that group, and give members of that group the exec permissions to these (only) commands.

Be warned, though, it's a security issue!

By the way, the DE allows for these things...any reason to expand on this?

Thor
 
Old 11-05-2011, 01:57 PM   #3
jefro
Moderator
 
Registered: Mar 2008
Posts: 16,489

Rep: Reputation: 2412Reputation: 2412Reputation: 2412Reputation: 2412Reputation: 2412Reputation: 2412Reputation: 2412Reputation: 2412Reputation: 2412Reputation: 2412Reputation: 2412
Push the power button if it is setup correctly in acpi and bios. A short push should shut it down.
 
Old 11-05-2011, 02:03 PM   #4
gujedan
Member
 
Registered: Oct 2010
Posts: 121

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by Thor_2.0 View Post
One immediate thought that pops in mind is to set up a group, add the non-privved user to that group, and give members of that group the exec permissions to these (only) commands.

Be warned, though, it's a security issue!

By the way, the DE allows for these things...any reason to expand on this?

Thor
ok, just out of pure interest how does it work with the DE? I don't start it as root so where does it pull the rights from?
 
Old 11-05-2011, 02:06 PM   #5
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,133
Blog Entries: 2

Rep: Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836Reputation: 4836
Quote:
Originally Posted by jefro View Post
Push the power button if it is setup correctly in acpi and bios. A short push should shut it down.
And how would you do that in a shell script? The OP is specifically asking how to use those commands in a script. Not the first time you failed to read the original question, and this is just a two-liner.

@gujedan: The default init-scripts can do that because they run with root-privileges. So you either have to run your script as root or you can setup a passwordless sudo for those commands.
 
Old 11-05-2011, 02:23 PM   #6
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,699
Blog Entries: 23

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
Quote:
ok, just out of pure interest how does it work with the DE? I don't start it as root so where does it pull the rights from?
Well, you (the non-privved user, that is) are either part of several groups, or are in a group with a set of privs on the system. For example, in the distro I use, I had to set up the first user (me, in fact) adding that user to several groups, one was "power" - users of that group were allowed to turn the thing off...

When you log on to a system, you "operate" or "exist" in several groups, each with a specific set of rights to the system...

Oh, and by the way, if you have a reasonably modern distro, you may not even be able to start/login as root...

Last edited by ButterflyMelissa; 11-05-2011 at 02:24 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] how to grant access to a non root users to reboot,halt,configure date and .... golden_boy615 Linux - General 5 12-18-2010 01:26 AM
halt/reboot as a non-root user Pau Gasol Slackware 3 10-05-2007 11:47 AM
Can't reboot or halt without being root. alex1986 Linux - Newbie 10 12-03-2005 07:25 PM
Tiny Sofa 2.0 - I thought "halt", "reboot" were only root command ?? sorcerer Linux - Distributions 1 08-21-2004 03:28 PM
Can only reboot or halt as root Kernel 2.6.5 Slackware 2 05-20-2004 08:07 AM


All times are GMT -5. The time now is 12:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration