2

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

Muhammad Omer
  • 543
  • 1
  • 8
  • 15

1 Answers1

1

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.

Community
  • 1
  • 1
ChuckCottrill
  • 4,360
  • 2
  • 24
  • 42