How to use pkexec to run a single type of command, from a single program, but without a password?
by A_UK_LinuxUser from LinuxQuestions.org on (#5GKP6)
Dear all
I have a Bash script called 'syncOut'. It contains, among its many commands, a single command with this form:
Code:pkexec rsync <arguments that are set by variables`I want the script to run the command with superuser privileges but without authentication. (I want that not to hold, though, for anything else in the script, and not for rsync commands run outside the script.) The script is run from the GUI (and specifically via a plugin to a graphically-running file manager).
I found some relevant guides on the web but they are hard for me to understand. I do have a fair amount of knowledge of Linux and of Bash but the guides seem somewhat unclear and/or not about my use case. I gather that I will need to create a pkexec policy file. But where? And what should it contain?
Thank you.
PS: Using either `sudo` or `gksudo` (or indeed `su`) does NOT suit my case.
PPS: I put this post on Reddit, initially - but it's not doing well there.


I have a Bash script called 'syncOut'. It contains, among its many commands, a single command with this form:
Code:pkexec rsync <arguments that are set by variables`I want the script to run the command with superuser privileges but without authentication. (I want that not to hold, though, for anything else in the script, and not for rsync commands run outside the script.) The script is run from the GUI (and specifically via a plugin to a graphically-running file manager).
I found some relevant guides on the web but they are hard for me to understand. I do have a fair amount of knowledge of Linux and of Bash but the guides seem somewhat unclear and/or not about my use case. I gather that I will need to create a pkexec policy file. But where? And what should it contain?
Thank you.
PS: Using either `sudo` or `gksudo` (or indeed `su`) does NOT suit my case.
PPS: I put this post on Reddit, initially - but it's not doing well there.