Linux reboot Command Explained

The reboot command in Linux restarts the operating system. It is commonly used to apply updates, clear temporary issues, or reinitialize system services.

This guide provides a detailed overview of the reboot command and demonstrates how to use it for restarting a Linux machine.

Syntax of the reboot Command

The basic syntax of the reboot command is as follows:

Here, the OPTIONS define how the system will restart.

Important Note

To run the reboot command, you must either be logged in as the root user or have sudo privileges.

Usage of the reboot Command

Running the command without any additional options will immediately restart the system.

Executing this command terminates all active processes, which may cause the loss of unsaved changes. After running it, the terminal session closes and the machine restarts.

How the reboot Command Works

The reboot command relies on systemd to interact with the init system, shutting down services before restarting the computer. It performs similar actions to the shutdown command before powering off the machine. This behavior can be overridden by using the -f (force) option, as explained in the next section.

Options for the reboot Command

The reboot command can be customized with the following options:

  • –force or -f: Immediately restarts the system without completing shutdown procedures, such as unmounting drives or notifying logged-in users.
  • –no-wall: Prevents the broadcast message from being displayed. Logged-in users are not warned before their sessions end.
  • –no-sync or -n: Skips writing pending buffer data to disks, usually applied only in emergencies.
  • –no-wtmp or -d: Prevents creating a reboot entry in the /var/log/wtmp file.
  • –wtmp-only or -w: Creates a log entry in /var/log/wtmp without actually rebooting the system.

Alternative Commands to reboot

Besides the reboot command, Linux offers other ways to restart the system:

Command Description
sudo systemctl reboot Uses systemd to initiate a system reboot.
sudo shutdown -r now Shuts down the system and restarts it immediately.

Conclusion

In this guide, you explored the reboot command, its syntax, usage, internal working, and available options. You also learned about alternative commands to achieve a system reboot. For more details, run:

Source: vultr.com

Create a Free Account

Register now and get access to our Cloud Services.

Posts you might be interested in: