For Linux distributions using systemd, is there a practical difference between these two commands?
systemctl suspend
pm-suspend
Which should I use or prefer?
For Linux distributions using systemd, is there a practical difference between these two commands?
systemctl suspend
pm-suspend
Which should I use or prefer?
In short, you should generally prefer the suspend mode integrated by your distro. For distros that ship systemd, that's typically systemctl suspend
.
For instance, the Arch Linux wiki says:
systemd provides native commands for suspend, hibernate and a hybrid suspend, see "Power management with systemd" for details. This is the default interface used in Arch Linux.
And for Debian Jessie:
With systemd,
pm-utils
and its hooks are not used any more, instead there'ssystemd-suspend
.
The reason why you want to stick with what your distro uses is that their packages which care about suspend/resume will ship hook scripts that integrate with either pm-utils
(/usr/lib/pm-utils/sleep.d
) or systemd
(/usr/lib/systemd/system-sleep/
), so you should use the same interface in order to have all the proper hooks run as expected.
Furthermore, distros will typically hook the proper suspend/hibernate method into ACPI for hardware events, desktop environments (for shutdown buttons that allow for suspend/hibernate), and with screen savers/locks, etc.
Both pm-suspend
and systemd-suspend
use typically the same interfaces to actually put the computer to sleep.
Both default to using the kernel's suspend driver (by writing to /sys/power/state
) and both support external suspend drivers (such as uswsusp
, see here for details on how to hook it into systemd.)
They both support configuration files and hook scripts that are called in the process of suspending or resuming, the main difference being the location of the files (the API of the hooks is very similar):
pm-utils
reads its configuration from files in /etc/pm/config.d
and executes hooks from both /etc/pm/sleep.d
and /usr/lib/pm-utils/sleep.d
directories.systemd-suspend
reads its configuration from the /etc/systemd/sleep.conf
file (or files in a sleep.conf.d
directory) and executes hooks from /usr/lib/systemd/system-sleep/
.So, from that point of view, both look very similar...
But systemd goes further into its support for suspend/hibernate/resume, since:
systemctl suspend
is still of course an option.) Triggering suspend through D-Bus rather than by running a command is typically useful from a desktop environment.So even though both pm-utils
and systemd-suspend
achieve the actual suspend of the system in about the same ways, the integration with the other components of the system makes it so that it matters which one is called... And on distributions shipping systemd, then systemctl suspend
is typically the right one to call.
pm-utils
installed by default and seems to rely onsystemctl
, but/usr/lib/pm-utils/sleep.d/
has things in it and/usr/lib/systemd/system-sleep/
doesn't exist. However, I do see/lib/systemd/system-sleep/
and several more under/snap/
, all of which have one or two files in them. – Izkata Jan 19 '20 at 04:21