running a command as a super user from a python script

后端 未结 8 1196
别跟我提以往
别跟我提以往 2020-11-28 06:15

So I\'m trying to get a process to be run as a super user from within a python script using subprocess. In the ipython shell something like

proc = subproces         


        
8条回答
  •  一整个雨季
    2020-11-28 07:09

    Another way is to make your user a password-less sudo user.

    Type the following on command line:

    sudo visudo
    

    Then add the following and replace the with yours:

     ALL=(ALL) NOPASSWD: ALL
    

    This will allow the user to execute sudo command without having to ask for password (including application launched by the said user. This might be a security risk though

提交回复
热议问题