The action of restarting the system is often used in Windows, usually after installing some software that requires a system restart to take effect. In this case, you typically click to confirm whether to restart now or later.
Naturally, if you click restart now, the system will automatically reboot. If you choose to restart later, you will have to manually find the system restart button in the menu to reboot.
In Linux, the frequency of system restarts is quite low, especially after software installations, where the need to restart the system is almost nonexistent.
Of course, this does not mean that the Linux system never needs to restart; for example, core software updates and some system configurations require a restart.
Using commands to restart in Linux is a very convenient operation. When it comes to the restart command, you might first think of reboot. Indeed, this is one of the restart commands, but there are other commands that can also achieve a reboot.
Typically, we would enter:
sudo reboot
Then, enter your password as prompted, and the system will begin to restart.
If, for some special reason, the system does not restart after reboot, you can force a restart by adding the parameter <span>-f</span>
.
sudo reboot -f
The difference between the two is that reboot will first send a signal to the init process to perform a series of operations before restarting the system, while adding <span>-f</span>
directly calls the kernel to restart.
In addition to the reboot command, the shutdown command can also achieve a restart effect. In most cases, you might think of shutdown as a command for shutting down, but it can also restart the system; you just need to enter the following command:
sudo shutdown -r now
Here, the <span>-r</span>
parameter indicates a restart, while <span>now</span>
means to perform this action immediately. If you do not add the <span>now</span>
parameter, it defaults to executing the restart one minute later.
Similarly, you can replace <span>now</span>
to specify a time for executing this action. For example, if you plan to restart in 10 minutes, you need to specify the time as follows:
sudo shutdown -r +10
This indicates that the system will restart in 10 minutes.
If you want to cancel the scheduled restart during this time, you can simply execute the following command:
sudo shutdown -c
If you want a more direct method to restart the system, you can also enter in the command terminal:
init 6
This method is more direct, but it is not as flexible as using reboot and shutdown commands, which can perform more operations.
If you want to learn more about the usage of reboot and shutdown commands, it’s very convenient; you just need to use the man command in the terminal to view them, like this:
man reboot
Actually, the Windows system also has a shutdown command, which can perform shutdown and restart operations. If you’re interested, you can search for it online.
However, in terms of command-line functionality, Windows and Linux cannot be compared; the command line in Linux is much more comfortable to use.
In Linux, a single restart command can be executed in various ways, not to mention other command operations.
