Question

Is there any way i can restart my computer running Ubuntu 13.04 using a Java application without needing any sudo rights?

Was it helpful?

Solution

No. You need root privileges to run shutdown/reboot.

However, you can exec a system command which has setuid root and runs shudown/reboot. Do you consider setuid/setgid equivalent to sudo for your question? Not recommended.

Here is how to run a system command, (How to execute system commands (linux/bsd) using Java).

Oh, and there is JNI (http://www2.sys-con.com/itsg/virtualcd/java/archives/0510/Silverman/index.html), again setuid.

Another way to shutdown the system would be to connect to a Tcpip controlled power switch. Then you could power off the system. Did you ensure security on your ehternet power switch? Powering the system back on is another challenge.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top