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

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:

ADVERTISEMENTS

  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

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
3 comments… add one
  • matt Aug 8, 2017 @ 7:38

    When talking about ipmi, why not to mention ipmitool, very powerful cli app, that is also able to restart remotely:
    ipmitool -H -U root -P chassis power reset

    • 🐧 Vivek Gite Aug 8, 2017 @ 8:01

      Yes, you are right about that. One can use ipmitool or java based client too.

  • alecthegeek Aug 9, 2017 @ 11:34

    It’s shorter to type `sudo init 0` :-)

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.