Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6794987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:17:19+00:00 2026-05-26T18:17:19+00:00

I am writing a pyQt client-server application which restarts/shutdowns PCs remotely. The receivers are

  • 0

I am writing a pyQt client-server application which restarts/shutdowns PCs remotely.
The receivers are listening to the network for incomming messages, and the sender sends a restart/shutdown message to the selected receiver.

The following part of code is running on a receiver:

import os

self.currentOS = calling a function to determine the current OS

if self.currentOS == "Win":
    os.system("shutdown -r -f -t 1")
elif self.currentOS == "Lin":
    os.system("shutdown -r now")

I have 2 virtual machines acting as receivers, one on Windows and the other on Linux.

When i send a restart message to the Windows receiver, the machine restarts.
When i send a restart message to the Linux receiver, it asks for password

Incoming:EXEC_OP_RESTART
[sudo] password for jwalker: 

What do i have to change to overcome this?
Is shutdown -r now the only way, or can i do this another way (more directly)?

EDIT:
In this question, something called dbus was used, and it was done without a password, i am searching about dbus, as an alternative.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:17:20+00:00Added an answer on May 26, 2026 at 6:17 pm

    It takes root privileges to restart a Linux machine. Some desktop environments use a daemon to get around this…. but I suggest editing the sudoers file

    https://help.ubuntu.com/community/Sudoers for a howto. Basically you’ll want to allow the restart command – and only the restart command – to be run without a password.

    Something like:

    ALL ALL=(ALL) NOPASSWD: /usr/sbin/shutdown
    

    will let any user on the machine restart it without using a password. You’ll probably need to prefix the ‘shutdown’ in your system command with ‘sudo’, though it looks like it’s being called automatically somehow. If this isn’t secure enough, you can make a group, make your program run as that group, then allow that group to restart.

    EDIT: Apparently this can be done with DBus (note: I haven’t tested this):

    dbus-send --system --print-reply --dest="org.freedesktop.Hal" /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Restart int32:0
    

    This works because dbus runs as root (or has root privs) and can therefore accept requests to restart from nonpriveleged processes and act on them. I still think the sudo way is cleaner, and so will anyone who maintains this code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a PyQt (Python bindings for the all-powerful Qt library) application and a
writing a server that runs on linux (Ubuntu) using mono. and a client that
Writing my first Linq application, and I'm trying to find the best way to
Writing a .NET DLL how do I find Application.ProductName ? EDIT: Obviously, importing Windows.Forms
Writing an iPhone app in which I want to save the user the grief
Writing a program in which I need to split strings from a struct linked
I have a PyQt application that reads and writes data files. I am including
Recently I'm writing a program using Qt(PyQt)'s QTableView. But I find that the current
I'm writing a program using PyQt and I'm trying to figure out a way
Writing my first silverlight application. I need to deliver some bitmap that the customer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.