Open In App

Reboot Linux System Command with Examples

Improve
Improve
Like Article
Like
Save
Share
Report

The reboot command is used to restart or reboot the system. In a Linux system administration, there comes a need to restart the server after the completion of some network and other major updates. It can be software or hardware that is being carried on the server. Rebooting is needed so that the changes that the user has made can affect the server. 

For example, if the user is re-compiling the server’s kernel that is going through some more advanced server administration, then he needs to restart the machine in order to complete the compilation and to have a new updated kernel version on the server. When updating the server’s memory, IP allocation, and NIC configuration are the key tasks that need to be done on the server restarted once leading to their successful implementation. Most Linux system administrators access their servers via shell or SSH to perform a bunch of administrative activities, server management, and monitoring. So, they need to know the basic commands to restart the server from the shell. 

Syntax of reboot command in Linux

reboot [OPTIONS...]
Options                                               Description
–help

This option prints a short help text and exit.

–halt

This option halts the machine, regardless of which one of the three commands is invoked.

-p, –poweroff

This option will be going to power off the machine, regardless of which one of the three commands is being invoked.

–reboot

 This option reboots the machine, regardless of which one of the three commands is invoked.

-f, –force

This option forces an immediate halt, power-off, or reboot. When it is specified once, this results in an immediate but clear shutdown by the system manager. When it is specified twice, this results in an immediate shutdown without contacting the system manager. See the description of the option –force in systemctl(1) for more details.

-w, –wtmp-only

 This option only writes wtmp shutdown entry, it does not actually halt, power-off, or reboot.

How to Restart 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

Restarting 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. 

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 s

pecifies 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: 

sudo shutdown –r +5 
sudo shutdown –r +5

sudo shutdown –r +5 

Reboot your system after 02:00 A.M: 

sudo shutdown –r 02:00
sudo shutdown –r 02:00

sudo shutdown –r 02:00

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.

$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"

3. Restarting our server remotely in Linux

Simply login your server with any of the ssh client using server authentication information and simply issue any of the following commands:

Syntax:

ssh root@remote-server.com /sbin/reboot

Example:

ssh root@196.162.1.1 /sbin/shutdown –r now\

4. Using init command to restart our Linux System

The Init command is actually taken from the word initialize that is widely been used to initialize/start different processes in a Linux machine, so this command used as a joint with the runlevel 6; a number which is been set for rebooting a Linux server leads to getting the server rebooted. The syntax for this is mentioned below:

Syntax:

init 6

OR

/sbin/init 6

5. Using systemctl to restart our Linux System

In Linux Distributions like Debain-based, CentOS, Fedora, Arch and RHEL, etc. These Linux distributions use sa system The `systemctl` command is a powerful utility in Linux System which allows us to manage the system and services manager.

Syntax:

To restart 

sudo systemctl reboot

 To shutdown

sudo systemctl poweroff

6. Using telinit command to restart our Linux System

The telinit command can be used to restart our linux system, to do so we can use the syntax mentioned below.

Syntax:

To restart

sudo telinit 6

To shutdown

sudo telinit 0

7. Checking your reboot logs:

 /var/log/wtmp is the file records in which all logins and logouts records are kept. One can parse this file with the last command in order to access log for the reboot. Below you can find the last command usage and its output on my system.

last reboot
last reboot

last reboot

Reboot Linux System Command [ Restart Linux ] – FAQs

How can I schedule a recurring reboot in Linux?

We can do this by using cron or system timers. These tools allow us to specify the time and frequency of reboot.

For example:

If we want to reboot our system at 2:30 AM every day in January and march, regardless of the specific day of the week or day of the month.

First open the crontab using 

sudo crontab -e

Now add this line.

30 2 * 1,3 * /sbin/reboot

It is at 2:30 AM every day in January and March, regardless of the specific day of the week or month.

This is in the format of:

* * * * * /path/to/script.sh

First `*` = minutes 

Second `*` = hours (24hrs format)

Third `*` = Day of the month

Fourth `*` = Month number 

Fifth `*` = The day of the week.

What is the impact of a reboot on running processes and services in Linux System?

Rebooting in Linux System will terminate all the running processes and services. It is important for users to save their work before rebooting the system.

How to reboot a remote Linux server?

To reboot a remote Linux server, you can use SSH to connect to the server and then execute the reboot command. Here’s an example:

ssh username@remote_server sudo reboot

Replace username with the username of the server you want to reboot and replace remote_server with the IP address of the server you want to reboot.

How can I force a reboot immediately in Linux?

If you need to force a reboot immediately without waiting for running processes to finish, you can use the -f option with the reboot command:

sudo reboot -f

This will forcefully reboot the system without performing a graceful shutdown.

What is the difference between reboot and shutdown -r now?

Both `reboot` and `shutdown -r now` commands can be used to reboot the system immediately. However, `shutdown -r now` provides additional options for scheduling reboots in the future or sending warning messages to users before rebooting.

How do I reboot my Linux system using the command line?

To reboot a Linux system from the command line, you can use the reboot command:

sudo reboot

This command will gracefully shut down the system and then reboot it.

Conclusion

The article provides comprehensive guidance on rebooting Linux systems through various methods, including the reboot command, shutdown command, init command, systemctl command, telinit command, and remote rebooting via SSH. It covers syntax, options, and examples for each method, offering practical solutions for both immediate and scheduled reboots. Additionally, the article addresses common FAQs, such as scheduling recurring reboots, the impact of reboots on running processes, remote server rebooting, forcing immediate reboots, and the differences between reboot and shutdown -r now commands. With this information, users can efficiently manage and execute system reboots in Linux environments, ensuring system reliability and stability.



Last Updated : 22 Mar, 2024
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads