Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: How to shutdown, restart, suspend and hibernate without being root ?

  1. #1
    Join Date
    Nov 2010
    Beans
    69

    Talking How to shutdown, restart, suspend and hibernate without being root ?

    Hi! How to shutdown,restart,suspend and hibernate your pc from a terminal or a shell prompt without being root... (so without a sudo before the command ) ....

  2. #2
    Join Date
    Apr 2007
    Location
    (X,Y,Z) = (0,0,0)
    Beans
    3,715

    Re: How to shutdown, restart, suspend and hibernate without being root ?

    Impossible with a default system setup. Shutting down is done through setting a particular runlevel and that's done by root.

    Now you may ask why you can shut down on GNOME or KDE not being root. Well, because what GNOME or KDE do is call the underlying gdm or kdm, which are run by root. You know, the whole desktop is like a big su-like (not sudo) login in which a process owned by root lets you enter into your non-privileged user account.

  3. #3
    Join Date
    Nov 2010
    Beans
    69

    Re: How to shutdown, restart, suspend and hibernate without being root ?

    ok so how is it possible from a program like GShutdown to shutdown the pc on the time you say? There must be a command that let's you do that.. :/

  4. #4
    Join Date
    Apr 2009
    Location
    Germany
    Beans
    2,134
    Distro
    Ubuntu Development Release

    Re: How to shutdown, restart, suspend and hibernate without being root ?

    you could use dbus:
    dbus-send --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.RequestShutdown

    you could probably also use setuid
    http://en.wikipedia.org/wiki/Setuid
    Last edited by MadCow108; January 6th, 2011 at 02:19 PM.

  5. #5
    Join Date
    Nov 2010
    Beans
    69

    Re: How to shutdown, restart, suspend and hibernate without being root ?

    Quote Originally Posted by MadCow108 View Post
    you could use dbus:
    dbus-send --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.RequestShutdown

    you could probably also use setuid
    http://en.wikipedia.org/wiki/Setuid
    Nice the shutdown command you said works! But this is only for shutdown.. For hibernate(halt), suspend(sleep), and lock screen?

  6. #6
    Join Date
    Jul 2006
    Location
    Here
    Beans
    9,689

    Re: How to shutdown, restart, suspend and hibernate without being root ?

    gnome-session-save --help
    &
    gtk-session-logout --help

    only works in gnome though.

  7. #7
    Join Date
    Apr 2009
    Location
    Germany
    Beans
    2,134
    Distro
    Ubuntu Development Release

    Re: How to shutdown, restart, suspend and hibernate without being root ?

    Quote Originally Posted by Bong.Da.City View Post
    Nice the shutdown command you said works! But this is only for shutdown.. For hibernate(halt), suspend(sleep), and lock screen?
    lock screen would be
    dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock

    PowerManager should have Suspend and Hibernate, but for some reason they are not present on my system :/

  8. #8
    Join Date
    Nov 2010
    Beans
    69

    Re: How to shutdown, restart, suspend and hibernate without being root ?

    Quote Originally Posted by MadCow108 View Post
    lock screen would be
    dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock

    PowerManager should have Suspend and Hibernate, but for some reason they are not present on my system :/
    Thanks again.. Lock also works!

    But these:
    dbus-send --session --dest=org.gnome.PowerManager --type=method_call --print-reply --reply-timeout=2000 /org/gnome/PowerManager org.gnome.PowerManager.Hibernate
    dbus-send --session --dest=org.gnome.PowerManager --type=method_call --print-reply --reply-timeout=2000 /org/gnome/PowerManager org.gnome.PowerManager.Suspend

    Gives an error
    Error org.freedesktop.DBus.Error.UnknownMethod: Method "Suspend" with signature "" on interface "org.gnome.PowerManager" doesn't exist

    Weird i have to say .. So any ideas ? I am searching at google but i can't find it :/

  9. #9
    Join Date
    Nov 2010
    Beans
    69

    Re: How to shutdown, restart, suspend and hibernate without being root ?

    Anyone? :/

  10. #10
    Join Date
    Apr 2009
    Location
    Germany
    Beans
    2,134
    Distro
    Ubuntu Development Release

    Re: How to shutdown, restart, suspend and hibernate without being root ?

    if all fails use a helper program with setuid or capabilities http://linux.die.net/man/7/capabilities

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •