shutdown form command without root.

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post please read this

shutdown form command without root.

Postby pokemoncatdog on Tue Oct 26, 2010 4:07 pm

I know about shutdown -h now and shutdown -r now but you need to be root for this. I mean what are the commands use for this.
Image

Shutdown
Restart
Suspend
Hibernate

What commands does this menu use?
I want to make desktop shortcuts. I do not want to have to use "gksudo" or "sudo".

OR What command does the "quit" item on the mint menu use to bring up the shutdown menu?

Thank you
pokemoncatdog
Level 2
Level 2
 
Posts: 53
Joined: Tue Dec 29, 2009 6:17 pm

Linux Mint is funded by ads and donations.
 

Re: shutdown form command without root.

Postby Elisa on Tue Oct 26, 2010 4:24 pm

you could try these commands if they work. I cannot test it now because if it'd work I don't want to turn off my PC for now :)
http://www.computerhope.com/issues/ch000606.htm
Linux/Unix is about freedom, Windows about slavery.

md5 / sha1 check [how-to for NEWBIES] :idea:

Image
Score: 43 I have some hippie in me. Cool, man 8)
Take the elitemrp.net "Are you a Hippie?" Test
User avatar
Elisa
Level 6
Level 6
 
Posts: 1425
Joined: Wed Aug 18, 2010 6:46 am

Re: shutdown form command without root.

Postby hemimaniac on Tue Oct 26, 2010 5:47 pm

First in terminal do;

sudo chmod u+s /sbin/shutdown

Then you simply need to do

shutdown [options] now or time
"Linux allows for one thing above all else - 'A user can truly be themselves!'"
Image
User avatar
hemimaniac
Level 5
Level 5
 
Posts: 508
Joined: Thu Feb 04, 2010 1:26 pm
Location: London ON

Re: shutdown form command without root.

Postby beefstu on Tue Oct 26, 2010 5:49 pm

To run a root command without having to type the password, you need to add that command to the sudoers file. to do that, first
Code: Select all
sudo visudo
then add the lines
Code: Select all
USERNAME ALL = NOPASSWD: /sbin/shutdown
where you need to replace USERNAME with the username of the account you want to be able to shutdown the computer.

To shut it down, you still need to do
Code: Select all
sudo shutdown now
but you will not need to type in a password.

Be warned though, adding commands to the sudoers file essentially overwrites one of Linux's inherent safety features


EDIT: hemimaniac wrote his post as I was writing mine, I can see his method working just as well but though I'd leave my reply here just incase its useful to someone!
Please go through the steps here when posting a question. Once your question has been resolved, edit the original question post and add [Solved] to the subject. Both of these will help others use the forum effectively.
User avatar
beefstu
Level 5
Level 5
 
Posts: 654
Joined: Tue Dec 29, 2009 10:22 am
Location: Southampton, UK

Re: shutdown form command without root.

Postby piratesmack on Tue Oct 26, 2010 6:07 pm

I think the commands to suspend/hibernate are 'pm-suspend' and 'pm-hibernate'

chmod +s won't work on these because they're shell scripts, so follow beefstu's advice to run these commands without a password.
piratesmack
Level 5
Level 5
 
Posts: 710
Joined: Mon May 26, 2008 3:08 pm

Re: shutdown form command without root.

Postby pokemoncatdog on Wed Oct 27, 2010 8:51 am

hemimaniac wrote:First in terminal do;

sudo chmod u+s /sbin/shutdown

Then you simply need to do

shutdown [options] now or time



This worked, thank you. Ok I can shutdown form desktop now, but is there a way to make the "quit" / shutdown menu open form shortcut. OR to have the shortcut open an "are you shore?" dialog box.
pokemoncatdog
Level 2
Level 2
 
Posts: 53
Joined: Tue Dec 29, 2009 6:17 pm


Return to Installation & Boot

Who is online

Users browsing this forum: austin.texas, cutiesagraz and 13 guests