Shutdown, Reboot, Suspend and Hibernate a Linux System

This tutorial explains how to perform various power management-related tasks, such as halt, power-off, shutdown, reboot, sleep (suspend), hibernate, and hybrid-sleep on a Linux system. We can categorize power management-related options into two types: essentials and advanced.

Essential power management options

These options turn off all running services and processes on the system. To start the system, we have to boot it again. The essential power management options are halt, power-off, shutdown, and reboot.

Halt

This mode terminates all processes and services and shuts down the CPU but does not power off the system.

Power-off

This mode functions similarly to the halt mode. However, it also powers off the system after terminating all processes and services.

Shutdown

This mode works similarly to the power-off mode. However, it allows the administrator to execute commands and custom scripts before terminating all processes and services. For example, he can broadcast messages to other users and run scripts for logging events and backing up data.

Reboot

This mode first performs the shutdown operation and then starts the system again. Usually, administrators use it to perform system management-related tasks such as detecting hardware or software changes or cleaning cache or turning off a hanged process or service.

Comparing halt, power-off, shutdown, and reboot

Mode/StateWhat does it do?What does it not do?
HaltTerminate all processes and services and shut down the CPU.Power off the system.
Power-offTurn off all services and processes, and send an ACPI command to the motherboard to terminate the power supply.Execute any command or script before turning off the system.
ShutdownExecute configured commands and scripts and shut down the system by following the process the power-off mode uses.Keep the system in a powered-on state.
RebootShut down the system by following the shutdown mode process and send a reboot ACPI command to the motherboard to start the system again.Keep the system in a powered-off state.

The following image shows a basic overview of all the above modess.

essential power management modes on Linux

Commands for essential power management tasks

To halt the system, use any one of the following commands.

#systemctl halt
#shutdown -H now
#halt

Use any one of the following commands to power off the system.

#systemctl poweroff
#shutdown -P now
#poweroff

To shut down the system, use any one of the following commands.

#systemctl poweroff
#shutdown

Use any one of the following commands to reboot the system.

#systemctl reboot
#shutdown -r
#reboot

Key points

  • The systemd utility manages all services and processes of the system.
  • The systemd utility provides systemctl halt, systemctl poweroff, and systemctl reboot commands to halt, power off, and reboot the system.
  • Before the systemd utility, the halt, poweroff, and reboot commands were used to halt, power off, and reboot the system. These commands are deprecated. For compatibility, the systemd links these deprecated commands to their new versions.
  • If we use any of these deprecated commands, the systemd executes the new linked command. For example, if we run the halt command, the systemd executes the systemctl halt command.

The shutdown command

The shutdown command allows us to perform all four operations: halt, power-off, shutdown, and reboot.

For example, the following command halts the system.

#shutdown -H now

The following command powers off the system.

#shutdown -P now

The following command shuts down the system.

#shutdown

The following command reboots the system.

#shutdown -r now

The shutdown command shuts down the system gracefully. Before shutting down all services and processes, it broadcasts a warning message to all logged-in users and runs any specified commands or scripts. It can also schedule the operation. Let's take a few more examples of this command.

The following command shuts down and powers off the system at 03:44 AM.

#shutdown -P 03:44

The following command halts the system after 10 minutes.

#shutdown -H 10

The following command reboots the system after 15 minutes.

#shutdown -r 15

The shutdown command accepts time in two formats: hh:mm and +mm, where hh:mm is the time in 24-hour format, and +mm is the delay time in minutes.

Advanced power management options

These options save the running state of the system and use the saved state to start the system again. Since these options restore the system from a saved state, the system does not boot again. Sleep, hibernate, and hybrid-sleep are the advanced power management options.

Sleep (suspend or standby)

This mode is also known as the standby, suspend, or suspend-to-ram mode. It saves the system's current state into the RAM and cuts the power supply of all devices except the RAM. When we start the system again, it restores the saved state from the RAM instead of booting it.

sleep or suspend mode

Since this mode saves the running state into the RAM, the power supply to the RAM must be retained. During this state/mode, if the system is on the battery and the battery entirely runs out or is on the power supply and the power supply is turned off, it deletes the saved state.

Hibernate

This mode is also known as the suspend-to-disk. It saves the system's current state to the disk and shuts down its power supply. Since it uses the disk to save the current state, the saved state does not depend on the battery or external power supply.

hibernate mode of linux

If we compare this mode with the sleep mode, restoring the system takes a few more seconds. However, it is more reliable than the sleep mode.

Hybrid-sleep

This mode is a combination of the hibernate and sleep modes. It stores the system's current state in the RAM and hard disk. After saving the system state in both places, it cut the power supply of all devices except the RAM. If the power supply to the RAM remains available until we start the system again, it restores the system from the saved state in the RAM. If not, it uses the state saved on the disk. Since both RAM and hard disk contain the same system state, the restore operation works similarly regardless of the state it uses to restore the system.

hybrid-sleep mode linux

Commands for essential power management tasks

The following command switches the system into sleep (suspend/standby) mode.

#systemctl suspend

To switch a system into the hibernate mode, use the following command.

#systemctl hibernate

The following command switches the system into the hybrid-sleep mode.

#systemctl hybrid-sleep

To bring the system back to normal condition, press the power key. If the saved state is available, instead of booting the system, Linux restores the system from the saved state.

Conclusion

Understanding various power management options is essential for effective system administration. By leveraging these options and commands, administrators and users can ensure better control over their Linux systems, improve performance, and maintain system integrity during power-related tasks.

ComputerNetworkingNotes Linux Tutorials Shutdown, Reboot, Suspend and Hibernate a Linux System

We do not accept any kind of Guest Post. Except Guest post submission, for any other query (such as adverting opportunity, product advertisement, feedback, suggestion, error reporting and technical issue) or simply just say to hello mail us ComputerNetworkingNotes@gmail.com