2.3. Shutting down, suspending, and hibernating the system
As a system administrator, you can use different power management options to manage power consumption, perform a proper shutdown to ensure that all data is saved, or restart the system to apply changes and updates.
2.3.1. Scheduling a system shutdown リンクのコピーリンクがクリップボードにコピーされました!
As a system administrator, you can schedule a delayed shutdown to give users time to save their work and log off the system. Use the shutdown command to perform the following operations:
Shut down the system and power off the machine at a certain time:
# shutdown --poweroff hh:mmWhere
hh:mmis the time in the 24-hour time notation. To prevent new logins, the/run/nologinfile is created 5 minutes before system shutdown.When you use the time argument, you can notify users logged in to the system of the planned shutdown by specifying an optional wall message, for example
shutdown --poweroff 13:59 "Attention. The system will shut down at 13:59".Shut down and halt the system after a delay, without powering off the machine:
# shutdown --halt +mWhere
+mis the delay time in minutes. You can use thenowkeyword as an alias for+0.Cancel a pending shutdown
# shutdown -cFor more information, see the
shutdown(8)man page on your system.
2.3.2. Shutting down the system using the systemctl command リンクのコピーリンクがクリップボードにコピーされました!
As a system administrator, you can shut down the system and power off the machine or shut down and halt the system without powering off the machine by using the systemctl command.
Prerequisites
-
You have the
rootaccess.
Procedure
Use the
systemctlcommand to perform any of the following tasks:Shut down the system and power off the machine:
# systemctl poweroffYou can pass now use --when option in the
systemctlcommand to specify a time.注記By default, running either of these commands causes
systemdto send an informative message to all users that are currently logged into the system. To preventsystemdfrom sending this message, run the selected command with the--no-wallcommand line option.
2.3.3. Restarting the system リンクのコピーリンクがクリップボードにコピーされました!
When you restart the system, systemd stops all running programs and services, the system shuts down, and then immediately starts again.
Prerequisites
-
You have the
rootaccess.
Procedure
Restart the system:
# systemctl reboot注記By default, when you use this command,
systemdsends an informative message to all users that are currently logged into the system. To preventsystemdfrom sending this message, run this command with the--no-walloption.
2.3.4. Optimizing power consumption by suspending and hibernating the system リンクのコピーリンクがクリップボードにコピーされました!
As a system administrator, you can manage power consumption, save energy on your systems, and preserve the current state of your system. To do so, apply one of the following modes:
- Suspend
- Hibernate
- Hybrid Sleep
- Suspend-then-hibernate
Prerequisites
- You have Root access.
Procedure
Choose the appropriate method for power saving:
SuspendSuspending saves the system state in RAM and with the exception of the RAM module, powers off most of the devices in the machine. When you turn the machine back on, the system then restores its state from RAM without having to boot again. Because the system state is saved in RAM and not on the hard disk, restoring the system from suspend mode is significantly faster than from hibernation. However, the suspended system state is also vulnerable to power outages. To suspend the system, run:# systemctl suspendHibernateHibernating saves the system state on the hard disk drive and powers off the machine. When you turn the machine back on, the system then restores its state from the saved data without having to boot again. Because the system state is saved on the hard disk and not in RAM, the machine does not have to maintain electrical power to the RAM module. However, as a consequence, restoring the system from hibernation is significantly slower than restoring it from suspend mode. To hibernate the system, run:# systemctl hibernateHybrid sleepThis combines elements of both hibernation and suspending. The system first saves the current state on the the hard disk drive, and enters a low-power state similar to suspending, which allows the system to resume more quickly. The benefit of hybrid sleep is that if the system loses power during the sleep state, it can still recover the previous state from the saved image on the hard disk, similar to hibernation. To hibernate and suspend the system, run:# systemctl hybrid-sleepSuspend-then-hibernateThis mode first suspends the system, which results in saving the current system state to RAM and putting the system in a low-power mode. The system hibernates if it remains suspended for a specific period of time that you can define in theHibernateDelaySecparameter. Hibernation saves the system state to the hard disk drive and shuts down the system completely. The suspend-then-hibernate mode provides the benefit of conserving battery power while you are still able to quickly resume work. Additionally, this mode ensures that your data is saved in case of a power failure. Suspend and then hibernate the system:# systemctl suspend-then-hibernate
2.3.5. Changing the power button behavior リンクのコピーリンクがクリップボードにコピーされました!
When you press the power button on your computer, it suspends or shuts down the system by default. You can customize this behavior according to your preferences.
2.3.5.1. Changing the behavior of the power button when pressing the button and GNOME is not running リンクのコピーリンクがクリップボードにコピーされました!
When you press the power button in a non-graphical systemd target, it shuts down the system by default. You can customize this behavior according to your preferences.
Prerequisites
- You have the administrative access
Procedure
Edit the
/etc/systemd/logind.confconfiguration file and set theHandlePowerKey=poweroffvariable to one of the following options:poweroff- Shut down the computer.
reboot- Reboot the system.
halt- Initiate a system halt.
kexec-
Initiate a
kexecreboot. suspend- Suspend the system.
hibernate- Initiate system hibernation.
ignore- Do nothing.
For example, to reboot the system upon pressing the power button, use this setting:
HandlePowerKey=reboot
2.3.5.2. Changing the behavior of the power button when pressing the button and GNOME is running リンクのコピーリンクがクリップボードにコピーされました!
On the graphical login screen or in the graphical user session, pressing the power button suspends the machine by default. This happens both in cases when the user presses the power button physically or when pressing a virtual power button from a remote console. You can select a different power button behavior.
Procedure
Create a local database for system-wide settings in the
/etc/dconf/db/local.d/01-powerfile with the following content:[org/gnome/settings-daemon/plugins/power] power-button-action=<value>Replace
<value>with one of the following power button actions:nothing- Does nothing .
suspend- Suspends the system.
hibernate- Hibernates the system.
interactiveShows a pop-up query asking the user what to do.
With interactive mode, the system powers off automatically after 60 seconds when pressing the power button. However, you can select a different behavior from the pop-up query.
Optional: Override the user’s setting, and prevent the user from changing it. Enter the following configuration in the
/etc/dconf/db/local.d/locks/01-powerfile:/org/gnome/settings-daemon/plugins/power/power-button-actionUpdate the system databases:
# dconf update- Log out and back in again for the system-wide settings to take effect.