Reputation: 553
Is there any way i can restart my computer running Ubuntu 13.04 using a Java application without needing any sudo rights?
Upvotes: 2
Views: 940
Reputation: 4444
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.
Upvotes: 1