The server can be rebooted or shut down in a variety of ways on a Linux system or with Linux VPS. A healthy system should reply to any command. However, a degraded server may require a hard reboot. Note that most of these commands will require a certain level of privilege to be executed successfully, either as superuser or with sudo, because rebooting a system is an administrative task, and rebooting or shutting down a multi-user system or server running critical processes is a disruptive activity.
This post will go over a handful of these approaches that can assist you with Linux reboots and shutdowns.
If you’re using a GUI Desktop Environment for Linux, such as Gnome, KDE, Mate, XFCE, or others, you’ll find a power button in the system/application menu that lets you logout, reboot, hibernate, or turn off the computer. Depending on the distribution, desktop environment, and OS version in use, the available options may differ slightly. However, power-related options will mostly certainly be found in available menus to adjust your system’s power condition.
When running Linux on a desktop or laptop, clicking the power button defaults to either putting the machine to sleep or shutting it down by sending the shutdown signal. The power settings on the system can be modified to change this option. However, it should only be used as a last resort if conventional instructions fail.
The power button on a remote server running Linux normally turns off the system. Those in remote data centres, on the other hand, have the option of being rebooted or shut off using the individual server vendors’ remote lights-out management CLI/GUI interfaces.
For systems that do not operate on systemd, the init (telinit) command provides options for changing the system’s run-level. You can use init to reboot a system by typing:
$ sudo init 6
The init command to use when halting a system is:
$ sudo init 0
When you use init to call a specific run-level, the system’s init process runs a sequence of init scripts in a precise order to ensure the system achieves the intended run-level. Run-level 6 is for rebooting the system, whereas run-level 0 is for halting it.
You can use the poweroff command to shut off a computer:
$ sudo poweroff
Alt + SysRq Combination
It’s difficult to bring a non-responsive, frozen system to a reboot or power off state. If you don’t have any other options, you can try pressing Alt + PrintScreen + a series of keys to reboot the machine immediately. Although it is not a favoured or advised approach, it can be utilised as a last resort.
Always remember that, as with any other non-graceful, forced reboot or shutdown option, there is a risk of data loss and damage while utilising this method. When using this option, make sure to follow system best practises for backups and redundancy.