LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Shutting down as a normal user (https://www.linuxquestions.org/questions/slackware-14/shutting-down-as-a-normal-user-808727/)

Josh000 05-18-2010 09:35 PM

Shutting down as a normal user
 
I know this has been asked before, but I just wanted to clarify things.

Is there any way to shutdown as a normal user without changing permissions?


I don't want to press ctrl+alt+del or the power button.

If I add a user to the power group on slackware, will that user have access to shutdown frm the commandline by running /sbin/shutdown -h now?

Or is the power group only used by DE's?

Is the only remaining solution to use sudo, other than manually changing permissions on the shutdown executable?

exvor 05-18-2010 09:39 PM

Quote:

Originally Posted by Josh000 (Post 3973498)

Is the only remaining solution to use sudo, other than manually changing permissions on the shutdown executable?

yes.

I am unsure what the power group actually does on slackware so I am at a loss to answer that question but the only way that I am aware of is to allow the user to use sudo to shutdown the machine. You can limit there use of sudo for only this task however instead of giving every user access to everything via sudo, which IMHO I do not understand why distros allow all users access to everything via sudo. Seams like a bad idea from a security standpoint.

Richard Cranium 05-19-2010 12:00 AM

If you are at runlevel 4, kdm will let you shut down/poweroff the machine. You don't have to be root (in fact, you aren't anyone since you aren't logged in).

Josh000 05-19-2010 12:06 AM

Sorry, I should have said I mean from the commandline. I don't use KDE or Gnome or XFCE, and was just after a commandline solution.

Richard Cranium 05-19-2010 12:43 AM

Ah.
As root:
Code:

visudo
and add the line "%power ALL = NOPASSWD: /sbin/shutdown"

You'll still have to use the command...
Code:

sudo /sbin/shutdown -h now
...but you won't be asked for a password.

The above line restricts the command to members of the power group.

"man sudoers" tells you more than you'd want to know about the sudoers file.

Josh000 05-19-2010 03:30 AM

I'm more than familiar with sudo, I was just hoping there was a solution that didn't rely on it.

bathory 05-19-2010 03:37 AM

Hi,

You can use a symlink, as /sbin/halt runs with setuid
Code:

ln -s /sbin/poweroff /usr/bin
Regards

Richard Cranium 05-19-2010 03:57 AM

Quote:

Originally Posted by bathory (Post 3973776)
Hi,

You can use a symlink, as /sbin/halt runs with setuid
Code:

ln -s /sbin/poweroff /usr/bin

Not true in Slackware64 13.0.

Code:

x@x:~$ ls -l /sbin/poweroff
lrwxrwxrwx 1 root root 4 2009-09-26 10:43 /sbin/poweroff -> halt*
x@x:~$ ls -l /sbin/halt   
-rwxr-xr-x 1 root root 12424 2008-09-25 12:31 /sbin/halt*

The man page for halt specifically mentions:
Quote:

If you're not the superuser, you will get the message `must be superuser'.

tommcd 05-19-2010 07:36 AM

In case anyone using XFCE is wondering about this, adding a user to the power group in Slackware will allow regular users to shutdown the computer from the desktop in XFCE. I forget why exactly this does not work in KDE.

Fidori 05-19-2010 10:15 AM

If you are a member of the power group, you can shutdown from the command line with:
Code:

dbus-send --system --print-reply --dest="org.freedesktop.Hal" /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown

Richard Cranium 05-19-2010 10:59 AM

Excellent!

samac 05-19-2010 11:01 AM

Or you can just press the off switch on your computer it is set to shut down gracefully.

samac

samac 05-19-2010 11:04 AM

Yep! it works

samac

Josh000 05-19-2010 10:41 PM

Unfortunatly, pressing the power button is not at all a solution.

The dbus command works,,,,it will be kind of a long alias, but if it gets the job done......:)

Richard Cranium 05-19-2010 11:18 PM

Why not just put it in a script?


All times are GMT -5. The time now is 06:50 PM.