shutdown form command without root.

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
pokemoncatdog

shutdown form command without root.

Post by pokemoncatdog »

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
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Elisa

Re: shutdown form command without root.

Post by Elisa »

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
hemimaniac

Re: shutdown form command without root.

Post by hemimaniac »

First in terminal do;

sudo chmod u+s /sbin/shutdown

Then you simply need to do

shutdown [options] now or time
beefstu

Re: shutdown form command without root.

Post by beefstu »

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!
piratesmack

Re: shutdown form command without root.

Post by piratesmack »

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.
pokemoncatdog

Re: shutdown form command without root.

Post by pokemoncatdog »

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.
Locked

Return to “Installation & Boot”