How to shutdown / reboot the remote Linux server from the CLI

Posted on in Categories , , , , last updated August 7, 2017

I am a new Linux sysadmin. How do I remotely shutdown or reboot the server from the CLI?

For stopping and restating the system use any one of the following command:

  1. halt command – stopping the system i.e. the system is powered off.
  2. reboot command – Restarting the system.
  3. shutdown command – The shutdown utility provides an automated shutdown procedure for super-users to nicely notify users when the system is shutting down, saving them from system administrators, hackers, and gurus, who would otherwise not bother with such niceties.

First, you need to ssh into the remote box and issue the following commands.

How to reboot the remote Linux server

The syntax is:
ssh user@server-name-here
Type the following command to reboot the box:
sudo reboot
Another option is:
ssh -t vivek@server1.cyberciti.biz 'sudo reboot'
OR use the shutdown command:
ssh -t vivek@server1.cyberciti.biz 'sudo shutdown -r 0'
OR
ssh -t vivek@server1.cyberciti.biz 'sudo shutdown -r now'
Sample outputs:

[sudo] password for vivek: 
Connection to server1.cyberciti.biz closed by remote host.
Connection to server1.cyberciti.biz closed.

You must pass the -t option to the ssh command to force pseudo-terminal allocation. The shutdown accepts -r option i.e. Linux is rebooted at the specified time. A value of zero indicates reboot the machine immediately.

How to shutdown the remote Linux server

The syntax is:
ssh user@server-name-here
Type the following command to reboot the box:
sudo halt
Another option is:
ssh -t vivek@server1.cyberciti.biz 'sudo halt'
OR use the shutdown command:
ssh -t vivek@server1.cyberciti.biz 'sudo shutdown -h 0'
OR
ssh -t vivek@server1.cyberciti.biz 'sudo shutdown -h now'
You must pass the -t option to the ssh command to force pseudo-terminal allocation. The shutdown accepts -h option i.e. Linux is powered/halted at the specified time. A value of zero indicates poweroff the machine immediately.

Use IPMI to shutdown/reboot server

The Intelligent Platform Management Interface (IPMI) allows you to control power of your server using the CLI or web interface. For example one can login to IPMI web interface and issue the command:

Fig.01: Use IPMI to perform a power control operation on your server
Fig.01: Use IPMI to perform a power control operation on your server

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

3 comment

Leave a Comment