How to Restart Linux System?
Restarting a Linux system is a fundamental administrative task that can be accomplished using several commands, each tailored for specific scenarios. Here’s a brief overview of the primary methods to restart a Linux system. The following are the different types of methods for restarting the Linux System:
1. Using reboot command to restart our Linux system
Syntax:
sudo reboot
We use `sudo` as a prefix when we use the `reboot` command because we want to execute the command with root privileges, and to ensure that we have the necessary permissions to perform a system reboot while maintaining system security and integrity.
Force Immediate reboot in Linux system:
sudo reboot -f
Here we have used `-f` option for an immediate reboot without any delay. It is used to reboot our system forcefully.
2. Using shutdown command restart our Linux System
a) Restarting Immediately
- The following command helps in restarting the linux system immediately:
sudo shutdown –r now
- Here we have used `-r` option to indicate that a restart is intended. And used `now` is an argument that will specify time of execution here it now means that to restart immediately.
Note that the usage of the reboot, halt, and poweroff is almost similar in syntax and effect. Run each of these commands with –help to see the details.
b) Scheduled a Restart
Simple reboot command has limited usage. The shutdown command is being used instead of the reboot command to fulfill much more advanced reboot and shutdown requirements. One of those situations is a scheduled restart. Following is the syntax which is being used to reboot your system after time defines by the TIME.
$sudo shutdown –r [TIME] [MESSAGE]
Here TIME has various formats. The simplest one is “now”, already been listed in the previous section, and tells the system to restart immediately. Other valid formats we have are +m, where m is the number of minutes we need to wait until restart and HH:MM which specifies the TIME in a 24hr clock.
Below are the examples and their respective outputs. Optional MESSAGE argument can be used to intimate the users prior to reboot to prevent the possible loss of data.
Command to reboot your system after 5 minutes
- The following command helps in rebooting your system after 5 minutes:
sudo shutdown –r +5
Reboot your system after 02:00 A.M
- The following command helps in rebooting your system at 2:00AM:
sudo shutdown –r 02:00
c) Cancelling Restart
If you want your system to discard the previously scheduled restart or shutdown you can simply call another shutdown command with the –c option and broadcast with it a message for the users about the cancellation of the restart.
- The following command will cancel the scheduled restart operation:
$sudo shutdown –c [MESSAGE]
Cancel your scheduled Reboot
The previously scheduled reboot can be canceled by the system administrator by simply issuing another shutdown command with the –c option and an optional message argument.
$sudo shutdown -c "our custom example of canceling a scheduled shutdown"
Reboot Linux System Command with Examples
Rebooting a Linux system is a fundamental administrative task necessary for applying updates, troubleshooting, or system maintenance. Various commands are available to reboot a Linux system, each with specific options and use cases. This guide explores essential reboot commands such as `reboot`, `shutdown`, and `init`, illustrating their usage with practical examples to ensure a smooth and controlled reboot process.
Table of Content
- What is Reboot in Linux System?
- What are the shutdown Commands on Linux?
- How to Restart Linux System?
- Rebooting a Linux System Responsibly
- Best practices for Rebooting Linux System Commands