Search code examples
linuxbashintellij-ideasudorun-configuration

Run bash script from IntelliJ as root


I have a bash script which needs root privileges. I run it by sudo ./script.sh.

I would like to create run configuration in IntelliJ IDEA, that runs this script with root privileges. It doesn't matter if it asks for password later.

Is it possible without running IDE as root or using tools like gksudo or gksu?


Solution

  • It was not super clear what Bash integration you use. Probably something like the plugin: BashSupport

    https://plugins.jetbrains.com/plugin/4230-bashsupport

    The runtime configuration window for this plugin seems not to expose permission configuration.

    Hence, a simple pragmatic solution could be to actually write two scripts.

    1. You keep your script as it is
    2. Create a second one that calls your current one with sudo

    sudo ./myscript.sh

    enter image description here