How to reboot another Mac via Terminal?

14

5

Recently my main computer freezes up more often, and instead of giving him the hard treatment by pushing the power button, I'd rather reboot him gently.

So I grab my laptop, fire up Terminal and login to my main computer.

ssh username@ip-address  

I enter my password and that’s how far I come every time. I know that I can kill single processes, but when I try the reboot or restart command, my laptop reboots, not the main computer which I logged into via ssh.

I think it is possible, so this goes out to the advanced terminal user (I'm a beginner).

patrick

Posted 2011-03-17T17:56:45.183

Reputation: 950

Answers

30

Once you've logged in via ssh then you need to use shutdown with the -r flag (for restart):

$ ssh username@ip-address
$ sudo /sbin/shutdown -r now

Or, to do it all in one command:

$ ssh username@ip-address sudo /sbin/shutdown -r now

Paul R

Posted 2011-03-17T17:56:45.183

Reputation: 4 717

7you can also type it all in one line "ssh user@host sudo /sbin/shutdown -r now" – Cyber Oliveira – 2011-03-17T19:14:57.957

1Thank you guys - works flawless and saves me some time. Luckily my computer hasn't had any freezes lately. – patrick – 2011-03-19T20:29:07.600