Linux reboot Command with Practical Examples

LinuxLinuxBeginner
Practice Now

Introduction

In this lab, we will explore the Linux reboot command and learn how to reboot the system immediately or schedule a reboot at a specific time. We will start by understanding the reboot command and its various options, then practice rebooting the system immediately, and finally, learn how to schedule a reboot using the shutdown command. This lab covers essential system monitoring and management skills for Linux administrators.

The reboot command is a commonly used tool for system administrators and users to restart the system. In this lab, we will cover the necessary steps to effectively manage system reboots, ensuring smooth and controlled system operations.

Linux Commands Cheat Sheet


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/SystemInformationandMonitoringGroup(["`System Information and Monitoring`"]) linux(("`Linux`")) -.-> linux/UserandGroupManagementGroup(["`User and Group Management`"]) linux/SystemInformationandMonitoringGroup -.-> linux/crontab("`Job Scheduling`") linux/UserandGroupManagementGroup -.-> linux/sudo("`Privilege Granting`") linux/SystemInformationandMonitoringGroup -.-> linux/time("`Command Timing`") subgraph Lab Skills linux/crontab -.-> lab-422883{{"`Linux reboot Command with Practical Examples`"}} linux/sudo -.-> lab-422883{{"`Linux reboot Command with Practical Examples`"}} linux/time -.-> lab-422883{{"`Linux reboot Command with Practical Examples`"}} end

Understand the reboot Command

In this step, we will explore the Linux reboot command and understand its usage. The reboot command is used to restart the system, which is a common task for system administrators and users.

First, let's check the manual page for the reboot command to understand its options and usage:

man reboot

The manual page provides information about the various options available with the reboot command, such as:

  • -f: Force the reboot, even if system is not in a proper state.
  • -i: Shut down all network interfaces before rebooting.
  • -p: Halt the processor.
  • -w: Only write a record of the reboot, but do not actually reboot.

Now, let's try running the reboot command without any options:

sudo reboot

Example output:

Broadcast message from root@labex (pts/0) (Fri Apr 14 12:34:56 2023):

The system is going down for reboot NOW!

As you can see, the system will immediately reboot after executing the reboot command.

Reboot the System Immediately

In this step, we will learn how to immediately reboot the system using the reboot command.

First, let's verify the current system uptime:

uptime

Example output:

 12:34:56 up 1 day, 12:34,  0 users,  load average: 0.00, 0.01, 0.05

Now, let's reboot the system immediately using the reboot command:

sudo reboot

Example output:

Broadcast message from root@labex (pts/0) (Fri Apr 14 12:34:56 2023):

The system is going down for reboot NOW!

After executing the reboot command, the system will immediately start the reboot process. Once the reboot is complete, you will be able to log back into the system.

Schedule a Reboot at a Specific Time

In this step, we will learn how to schedule a system reboot at a specific time using the shutdown command.

The shutdown command is used to shut down or reboot the system, and it can be used to schedule a reboot at a specific time. Let's explore how to use it:

sudo shutdown -r +5

This command will schedule a reboot in 5 minutes. You can replace +5 with a specific time, such as 16:30 to reboot the system at 4:30 PM.

To cancel a scheduled reboot, you can use the following command:

sudo shutdown -c

This will cancel the scheduled reboot.

Let's try scheduling a reboot in 1 minute and then canceling it:

sudo shutdown -r +1

Example output:

Broadcast message from root@labex (pts/0) (Fri Apr 14 12:34:56 2023):

The system is going down for reboot in 1 minute!

After 1 minute, the system will reboot. However, let's cancel the scheduled reboot:

sudo shutdown -c

Example output:

Broadcast message from root@labex (pts/0) (Fri Apr 14 12:34:56 2023):

The system shutdown has been cancelled.

Now, the scheduled reboot has been canceled, and the system will not reboot.

Summary

In this lab, we first explored the Linux reboot command and its various options, such as forcing a reboot, shutting down network interfaces, and halting the processor. We then learned how to immediately reboot the system using the reboot command, verifying the current system uptime before executing the command. Finally, we discovered how to schedule a system reboot at a specific time using the shutdown command, which provides more control over the reboot process.

Linux Commands Cheat Sheet

Other Linux Tutorials you may like