Advertisement

How to enable shutdown and reboot for a normal user in Debian Jessie

Although I use Windows as well and our blog has primarily been about Windows so far, I also use Linux regularly. I just installed Debian Jessie on my work PC and noticed that none of the shutdown actions work from the GUI. The Desktop Environment I've installed is Mate, the fork of the good old Gnome 2. Every time I try to execute some shutdown action, the system requests for the root password. In this article, I would like to share with you an easy way to get it working and get rid of the root password request.

Advertisеment


Just follow these instructions:
  1. Open your favorite terminal and switch to the root session.
  2. Make sure you have installed the cksession and policykit packages. If not, install them (for Mate DE, I will install a policykit agent too):
    # apt-get install policykit-1 mate-polkit consolekit
  3. After you get these packages installed, you need to correct the policies to allow normal users to shutdown your PC. This can be done with simple file editing.
    Again, from the root terminal you should edit the following text file (I prefer mcedit as my text editor):
    mcedit /usr/share/polkit-1/actions/org.freedesktop.login1.policy

    It is a regular XML file.
    Find the following line:

     <action id="org.freedesktop.login1.power-off">

    Correct the sections inside the action block to make it look like this:

    <action id="org.freedesktop.login1.power-off"> 
                    <description>Power off the system</description> 
                    <message>Authentication is required for powering off the system.</message> 
                    <defaults> 
                            <allow_any>yes</allow_any> 
                            <allow_inactive>yes</allow_inactive> 
                            <allow_active>yes</allow_active> 
                    </defaults> 
            </action>
    
  4. Edit the defaults block similar to the example above in the following sections:
    <action id="org.freedesktop.login1.power-off-multiple-sessions"> 
    <action id="org.freedesktop.login1.reboot"> 
    <action id="org.freedesktop.login1.reboot-multiple-sessions"> 
    <action id="org.freedesktop.login1.suspend"> 
    <action id="org.freedesktop.login1.suspend-multiple-sessions"> 
    <action id="org.freedesktop.login1.hibernate"> 
    <action id="org.freedesktop.login1.hibernate-multiple-sessions">

    debian policy

That's it. Now simply reboot your OS (in my case, it started working even without rebooting). The power actions will now work without gksu/elevation requests.

Support us

Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:

If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!

Advertisеment

Author: Sergey Tkachenko

Sergey Tkachenko is a software developer who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.

4 thoughts on “How to enable shutdown and reboot for a normal user in Debian Jessie”

  1. This covers GUI shutdown actions only, correct? How about console-initiated shutdown from a user?

    Thanks for the article,
    regards,
    mewmew

    1. You are right. For console, I did the following:
      # apt-get install sudo
      # export EDTIOR=/usr/bin/mcedit
      # visudo

      In the sudoers file, I defined the wheel group and allowed poweroff/systemctl things.
      %wheel ALL= NOPASSWD: /sbin/halt, /sbin/poweroff, /sbin/reboot
      %wheel ALL= NOPASSWD: /usr/bin/systemctl poweroff, /usr/bin/systemctl reboot

      To allow yourself to run these commands do the following:
      # groupadd wheel
      # usermod -aG wheel your_login_here

      Now, edit ~/.bashrc:
      $ mcedit ~/.bashrc
      Add the following lines:
      alias poweroff='sudo /sbin/poweroff'
      alias reboot='sudo /sbin/reboot'

      or
      alias poweroff='sudo systemctl poweroff'
      alias reboot='sudo systemctl reboot'

      Also, (I not sure), it is quite possible that systemctl can allow you to shutdown/reboot PC without elevation.

Leave a Reply

Your email address will not be published.

css.php
Using Telegram? Subscribe to the blog channel!
Hello. Add your message here.