0

I am new to Linux help me on the following:

How to restart the linux machine using Java and it tried using Runtime.exec method using the following command sudo shutdown -r now and it asks for password, how do i proceed from here.Please help me out.

  • 1
    Have a look at this question http://stackoverflow.com/questions/233217/pass-password-to-su-sudo-ssh – SlappyTheFish May 10 '11 at 10:09
  • It is difficult to supply "sudo" with a password programmatically. Also the password then needs to be managed (i.e. how does it handle changes? How is it protected from unauthorised access etc) – MarkR May 10 '11 at 10:22

1 Answers1

4

You will need to configure sudo so that your user does not require a password to execute the reboot command.

This is straightforward; read the man page for sudoers.

The command

reboot

Is a shortcut.

MarkR
  • 62,604
  • 14
  • 116
  • 151