Reboot a Server from Command Line?

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.

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

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):

[email protected]:~# shutdown -r -h +0

Broadcast message from [email protected]
        (/dev/pts/10) at 14:41 ...

The system is going down for halt NOW!
[email protected]:~#

Solution 4

An alternate way:

sudo init 6

[NOTE]:

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

Solution 5

If you want to reboot your system, using @Jay’s solution, you’ll notice that the reboot will be scheduled by one minute. If, instead, you want your system to reboot immediately, you can use the following command:

reboot -f

The -f parameter will force your reboot to happen as soon as you enter the command.

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply