简体   繁体   中英

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 ?

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

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM