Reboot a Server from Command Line?

437,069

Solution 1

Try using the following command to safely reboot:

sudo reboot

If, instead, you want to shut down the server safely, use this command:

sudo shutdown -h now

Solution 2

For reboot, type the following

sudo shutdown -r now

Solution 3

As an alternative to sudo shutdown -r now, this command also effects an immediate shut-down:

sudo shutdown -h +0

Add the -r command to reboot:

sudo shutdown -r -h +0

Output (running as root):

root@mydevwkstn:~# shutdown -r -h +0

Broadcast message from cjbs@mydevwkstn
        (/dev/pts/10) at 14:41 ...

The system is going down for halt NOW!
root@mydevwkstn:~#

Solution 4

An alternate way:

sudo init 6

[NOTE]:

Without the init program there could be no command interpreter process.

Share:
437,069
Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin over 1 year

    How do I reboot a Ubuntu Server from the command line? sudo reboot now never seems to work for me. Because its a server, I don't have a window manager installed, so I can't do it from a GUI (which always seems to work).

    enter image description here

    I've had the problem for years on different versions of the operating system. It happens in virtual machines and on real metal. The same problem exists with sudo shutdown now, too.

    I've lived with it in the past. The difference now is I don't want to just hit the power button because I might lose data.

    • ASCIIbetical
      ASCIIbetical over 10 years
      Have you tried sudo shutdown -r now ?
    • sourav c.
      sourav c. over 10 years
      sudo reboot now is not a valid option. see man 8 reboot
    • Admin
      Admin over 10 years
      Thanks souravc - that's interesting. The command never complains about an invalid option. I'll test some of these when I get out of mysql.
    • Danatela
      Danatela over 10 years
      sudo init 6 must always work. Also, there are Ctrl+Alt+Del and REISUB.
  • rap-2-h
    rap-2-h over 6 years
    You did not mention "safely" in the sudo reboot method, it may mislead some users.
  • wisbucky
    wisbucky about 6 years
    @rap-2-h Wait, so do you mean sudo reboot is safe or not safe?
  • Jay
    Jay about 6 years
    @wisbucky : sudo reboot is safe
  • Gansheim
    Gansheim almost 6 years
    had a debate with a coworker about this today. Is this method preferred over sudo poweroff?
  • Jay
    Jay almost 6 years