Suspend, hibernate and shutdown Linux from command line
Exploring the differences between suspending, hibernating and shutting down a computer with Ubuntu.
In Ubuntu, power management commands are handled with
“systemd is a suite of basic building blocks for a Linux
system. It provides a system and service manager that runs as PID 1
and starts the rest of the system."1 and services are
simply unit configuration files whose name ends in
The system’s power management can be done in several ways:
- Power Off
- “Print a wall message to all users, shut down and power-off the system.” 2
- “Print a wall message to all users, shut down and reboot the system."3
- HybridSleep hibernated+suspended
The basic idea of putting a computer to sleep is to change its state into a “pausing mode”, so when we resume its operation, we have the same applications running and files opened as we had before sleep.
Main strategies involves using volatile storage like RAM or non-volatile memory HDD
Suspend saves its state to the RAM , hibernation saves it to disk.
Suspension is quicker but doesn’t work when running out of energy, while hibernating can deal with running out of power but it is slower.
|#||Suspend / Sleep||Hibernate|
|Saves state into||RAM||HDD|
|Requirements||Continuous power supply.||Swap space.|
|Resume time||Fast. Recovers data from RAM||Slow. Has to deal with disk's lower response time.|
|Risk of data loss||In a power outage||No risk. Data is saved in non-volatile storage|
Suspend means basically to **Suspend to RAM ** to consume less energy.
when placed in sleep mode, the computer cuts power to unneeded subsystems and places the RAM into a minimum power state, just sufficient to retain its data. Because of the large power saving, most laptops automatically enter this mode when the computer is running on batteries and the lid is closed
From command line it can be called with: systemctl suspend
- systemd files
Hibernate, or Suspend to Disk, “is powering down a computer while retaining its state”.4
saves all computer operational data on the fixed disk before turning the computer off completely. On switching the computer back on, the computer is restored to its state prior to hibernation, with all programs and files open, and unsaved data intact. In contrast with standby mode, hibernation mode saves the computer's state on the hard disk, which requires no power to maintain, whereas standby mode saves the computer's state in RAM , which requires a small amount of power to maintain
From command line it can be executed with: systemctl hibernate
- systemd files
hybrid-sleep Hibernate and suspend the system
A third approach is to suspend to copy the contents to RAM , and then hibernate which would also copy the contents of the RAM to the disk, so the power on is faster than powering on a computer and restoring the state manually.
From command line it can be executed with: systemctl hybrid-sleep
Suspend & hibernate
“Suspend the system, wake after a period of time and put it into hibernate”5
From command line it can be executed with: systemctl suspend-then-hibernate
- Suspend & Hibernate
- To suspend from command line: systemctl suspend.
- To hibernate: systemctl hibernate.
- An hybrid approach: systemctl hybrid-sleep
- Suspend and hibernate: systemctl suspend-then-hibernate
- Difference between suspend and hibernate in Ubuntu and how to execute them from command line
- Solving Google Chrome's gpu-process error message in Ubuntu LinuxJanuary 7, 2019
- Solving Google Chrome's secret service operation error message in Ubuntu LinuxJanuary 7, 2019
- Start Emacs In Ubuntu The Right WayJune 10, 2017