0

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.

7
  • 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. 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 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. 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? 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. Dec 10 '15 at 14:30
2

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.

5
  • /bin/bash: shutdown: command not found Dec 10 '15 at 14:17
  • 1
    Sorry, should've added you have to be root. Will update answer Dec 10 '15 at 14:20
  • Is it working better now? Dec 10 '15 at 14:23
  • Permission denied, please try again. is it because of my server system is not allowing ? 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. Dec 10 '15 at 14:30

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