How can I shut down and restart local machine from terminal?

How can I shut down and restart remote systems from terminal. I have remote IP.

closed as too broad by David Foerster, user117103, Eric Carvalho, Jacob Vlijm, Mark Kirby Dec 15 '15 at 9:19

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Welcome to Ask Ubuntu! We're sorry, but Ask Ubuntu is not a forum, but a Question & Answer site: it works best if you ask one question, so you can receive one answer. When you ask multiple questions, you need to find one expert versed in multiple areas, which becomes unlikelier the more questions you put into, well, one question! ;-) So please, split up your question into multiple questions and drop me a comment so I can answer one of your questions. – David Foerster Dec 10 '15 at 14:17
  • @DavidFoerster Okay thanks next time will take care.. but i thought both should under same command thts why i asked in same – user1140237 Dec 10 '15 at 14:19
  • You generally use different commands to shut down local vs. remote systems, since one needs to establish some communication protocol with remote machines first. Of course, you can access network services on the local machine through the loopback network to shut down the local machine. – David Foerster Dec 10 '15 at 14:22
  • Okay @DavidFoerster i'll take care next time ... Sorry :) now if you can thn can you please answer if possible than it would be helpful? – user1140237 Dec 10 '15 at 14:25
  • 1
    Running the danger of repeating myself, please, split up your question into multiple questions and drop me a comment so I can answer one of your questions. – David Foerster Dec 10 '15 at 14:30
up vote 2 down vote accepted

For remote systems, you can do ssh <user>@<ip> sudo -c "shutdown -hf now" for shutdown or ssh <user>@<ip> sudo -c "shutdown -rf now" for restart.

For local systems, you can do sudo shutdown -hf now for shutdown or sudo shutdown -rf now for restart.

  • /bin/bash: shutdown: command not found – user1140237 Dec 10 '15 at 14:17
  • 1
    Sorry, should've added you have to be root. Will update answer – Wilhelm Erasmus Dec 10 '15 at 14:20
  • Is it working better now? – Wilhelm Erasmus Dec 10 '15 at 14:23
  • Permission denied, please try again. is it because of my server system is not allowing ? – user1140237 Dec 10 '15 at 14:28
  • Possibly yes. If ssh <user>@<ip> gives the same output definately. In that case you should open a new question regarding SSH. The gist of it is, if you want to login as root via SSH you need to edit /etc/ssh/sshd_config to allow root login. – Wilhelm Erasmus Dec 10 '15 at 14:30

Not the answer you're looking for? Browse other questions tagged or ask your own question.