The process of rebooting a Linux server seems like a mundane task. In reality, it is not so simple. Rebooting can lead to unforeseen consequences, ranging from information loss to operating system crash. Let's take a look at how to safely reboot a Linux server.
When you may need to reboot
Before proceeding to remotely restart the server, make sure that it is really necessary. Interruption of work without an important reason can lead to malfunctions in the server hardware. In what cases should I restart the server?
- The server hangs or slows down.
- When installed programs are not working correctly.
- When changing the operating system.
- When working with BIOS (if there is physical access or its emulation).
- When using programs for low-level data copying and recovery (for example, Acronis Backup).
Also remember: you should not reboot the server while installing/uninstalling programs.
Ways to restart the server
A reboot can be soft or hard. Soft reboot is safer - after receiving a command, the server waits for all processes to complete correctly before stopping and restarting. Hardware reboot occurs through a brief power failure (similar to pressing the reset button on a computer - loss of information or corruption of some data is possible. Therefore, a hardware reboot is a last resort, used when other methods are not acceptable.
Reboot via console
How to restart the server via console? We recommend using SSH to connect to the server remotely. To reboot Linux servers, there are 3 easy ways to reboot it via console: shutdown, reboot and init commands.
The command to reboot a server in Linux with Ubuntu:shutdown -r now
You can also schedule a reboot for a specific time via the command line:shutdown -r 11:00
Or after a certain amount of time:shutdown -r +5
To reboot servers running Ubuntu, Debian, CentOS or other distributions, use the command:reboot now
After entering this command, the connection to the server will be disconnected.
You can also use the command using the Init Scripts initialization system levels:init 6
If there is no superuser status - Linux uses the built-in D-Bus utility. This method is relevant in case the graphical shell does not respond. It is necessary to perform several steps:
- Start a terminal and run the command:
echo 1 > /proc/sys/kernel/sysrq
- Open the configuration file in a text editor, for example:
sudo nano /etc/sysctl.conf
- Add the following line to the end of the file:
kernel.sysrq = 1
- Save the changes by clicking
Ctlr + O
andCtrl + X
- Press
Alt + SysRq
+R E I S U B
keys simultaneously at one second intervals.
You can also use only the SysRq key by first writing the operation code to the /proc/sysrq-trigger file:
echo b > /proc/sysrq-trigger
To reboot in Recovery Mode, select the appropriate item in the console and run the reboot command.
Conclusion
If after rebooting the server does not work - you should connect via IP-KVM to find out its current state. In case of problems, it is also recommended to contact technical support.
It is important to remember that rebooting is not always the only solution to a problem. Before rebooting the system, make sure that it is really necessary.