SystemD - Shutting Down, Suspending, and Hibernating the Linux System (part 3)
3. SystemD - Shutting Down, Suspending, and Hibernating the Linux System
The systemctl
utility from systemd replaces a number of power management commands used in previous versions of many linux distros like reboot
, poweroff
, halt
and many more. We learn Power Management Commands with systemctl command that replace old power management commands.
systemctl
when possible.
Table 3.1 - Comparison of Power Management Commands with systemctl
Old Command | New Command | Description |
---|---|---|
halt | systemctl halt |
Halts the system. |
poweroff | systemctl poweroff |
Powers off the system. |
reboot | systemctl reboot |
Restarts the system. |
pm-suspend | systemctl suspend |
Suspends the system. |
pm-hibernate | systemctl hibernate |
Hibernates the system. |
pm-suspend-hybrid | systemctl hybrid-sleep |
Hibernates and suspends the system. |
3.1 Shutting Down the System
systemctl
utility provides commands for shutting down the system, however the traditional shutdown command is also supported. Although the shutdown
command will call the systemctl
utility to perform the shutdown, it has an advantage in that it also supports a time argument
. This is particularly useful for scheduled maintenance and to allow more time for users to react to the warning that a system shutdown has been scheduled. The option to cancel the shutdown can also be an advantage.
Using systemctl Commands
To shut down the system and power off
the machine, type the following at a shell prompt as root
:
~] systemctl poweroff
To shut down and halt the system without powering off
the machine, run the following command as root
:
~] systemctl halt
By default, running either of these commands causes systemd to send an informative message to all users that are currently logged into the system. To prevent systemd from sending this message, run the selected command with the --no-wall
command line option, for example:
~] systemctl --no-wall poweroff
Using the old shutdown Command
To shut down the system and power off
the machine at a certain time, use a command in the following format as root
:
~] shutdown --poweroff hh:mm
Where hh:mm
is the time in 24 hour clock format. The /run/nologin
file is created 5 minutes before system shutdown to prevent new logins. When a time argument is used, an optional message, the wall message, can be appended to the command.
To shut down and halt the system after a delay, without powering off the machine
, use a command in the following format as root
:
~] shutdown --halt +m
Where +m
is the delay time in minutes. The now keyword is an alias for +0.
shutdown --halt now
command - The now
keyword is an alias for +0.
root
user as follows: shutdown -c
3.2 Restarting the Linux System
To restart the system, run the following command as root
:
~] systemctl reboot
By default, this command causes systemd to send an informative message to all users that are currently logged into the system. To prevent systemd from sending this message, run this command with the --no-wall
command line option:
~] systemctl --no-wall reboot
3.3 Suspending the System
To suspend the system, type the following at a shell prompt as root
:
~] systemctl suspend
3.4 Hibernating the System
To hibernate the system, type the following at a shell prompt as root
:
~] systemctl hibernate
systemctl hybrid-sleep
Another parts of this guide: