Learning how to reboot CentOS 8 using command line is vital to restarting your system after an important task, and we are here to help you to achieve that task.
Unlike Windows OS, Linux OS can operate for a longer time without requiring a reboot. However, a few crucial OS tasks, such as kernel updates or security patches, require a reboot. In addition, network activity or other significant updates also require a restart. Most Linux users use the reboot command to restart the system. However, similar to any task, there are multiple ways to achieve this task as well.
In this article, we will look at how you can reboot the CenOS 8 system using the command line in several ways. So, let’s get started!
Rebooting CentOS 8 Version – Quick Info
While rebooting CentOS versions greater than 7, the reboot, shutdown, and halt commands use symlink linked with systemctl to handle the reboot. The symlink is a symbolic link in the Linux file systems that usually links to other files or a connected file system. The systemctl command detects links through a symlink and runs the commands with their corresponding arguments.
Hence while shutting down the system, the systemctl initiates the shutdown run-time of the system, also known as systemd scripts. Systemd scripts are also called init scripts. The shutdown commands make use of this script to note down the time stamp in the init script and then proceed to shutdown. However, if you use the -f flag, then the system skips writing the timestamp and proceeds to shut down.
How to Reboot CentOS 8 Using Command Line
There are 3 major methods to reboot CentOS 8 systems: via keyboard shortcut, via GUI, and using Command-line. Since the article focuses on rebooting the system using the command line, so we will discuss that below in detail:
Reboot CentOS 8 Using the Reboot Command
It is the most common way to restart the machine. Hence, it is widely used by administrators and users alike. Open the terminal by pressing “Ctrl + Alt + T” and execute the command given below:
As soon as you press the Enter key, your system will reboot in a few seconds. Alternatively, use the
-f flag to force the reboot. For instance, type:
sudo reboot --force
sudo reboot -f
In addition, you can also use the
-h flag with the
reboot command. Specifically, type:
sudo reboot -h
The difference between the
-f flag and the
-h flag is that
-f invokes a clean reboot via the system manager, while
-h reboots the machine after halting the process.
Reboot CentOS 8 Using the Poweroff Command
As the command name indicates, power off turns the system off. In other words, it is used to shut down the system. However, to utilize this command to reboot the system, add the –reboot option. Specifically, type:
sudo poweroff --reboot
After pressing the “Enter” key, the system will reboot.
Reboot CentOS 8 Using the Shutdown Command
poweroff command, the shutdown command also turns the system off. However, you can add the
–reboot option with this command too. The syntax would look something like this:
sudo shutdown --reboot
sudo shutdown -r
It will reboot the system at once.
On the other hand, you can also use the
now option with this command. For example:
sudo shutdown -r now
However, this option is reported to have caused MySQL issues if you have it installed.
By using the shutdown command, you can also schedule the reboot for your system. For instance, to schedule the reboot at a particular time, the syntax would look something like this:
sudo shutdown -r [TIME] [MESSAGE]
# schedule reboot at 03:00 AM sudo shutdown -r 03:00
Let’s assume you have scheduled a reboot, and now you want to cancel it. For this scenario, use the
-c flag. Type:
sudo shutdown -c [MESSAGE]
sudo shutdown -c "an example to cancel a scheduled reboot"
Reboot CentOS 8 Using the Halt Command
One more way to reboot the CentOs system is using the
halt command. The syntax for this command is:
sudo halt –reboot
Reboot CentOS 8 Using the Telinit Command
The last method to restart the system is via the
telinit command. Make sure to add 6 with the command as shown below:
sudo telinit 6
The 6 number indicates runlevel 6, associated with the reboot operation in Linux machines. On the other hand, runlevel 0 indicates a shutdown operation.
Reboot CentOS 8 Using the SSH Server Terminal
If the system is located in a remote location, and you want to reboot it, use the SSH terminal for this task. First, open the SSH terminal. After that, type the
ssh command along with the
reboot command. Specifically, type:
ssh –t [email protected] 'sudo reboot'.
In this guide, we have discussed six methods to reboot CentOS 8 using the command prompt. After a successful reboot, the new implementations, patches, and updates will work properly. For any network configuration, the reboot would work too.
If you want to know more about the Reboot command, you can check out the official documentation, where you can learn more about all of the available features and their full capabilities.
If this guide helped you, please share it.