如何判断ProcessBuilder有root权限
时间: 2023-09-22 22:05:49
浏览: 173
### 回答1:
[proc](https://geek.csdn.net/educolumn/535f08ce32f749725902114bc56ad7b8?spm=1055.2569.3001.10083)essBuilder没有root权限,但是可以使用ProcessBuilder来启动一个具有root权限的进程。在Linux[系统](https://geek.csdn.net/educolumn/073441cd796e7450c3f98600b0cbeb95?spm=1055.2569.3001.10083)中,可以使用sudo[命令](https://geek.csdn.net/educolumn/4641683097031caa4ae7258fda89dcae?spm=1055.2569.3001.10083)来获取root权限,ProcessBuilder可以通过以下[方式](https://geek.csdn.net/educolumn/0a7fca90472e8d39fd3078246e0b14f3?spm=1055.2569.3001.10083)使用sudo[命令](https://geek.csdn.net/educolumn/4641683097031caa4ae7258fda89dcae?spm=1055.2569.3001.10083)来启动一个具有root权限的进程:
```java
ProcessBuilder builder = new ProcessBuilder("sudo", "command");
```