All Linux systems have a number of options built into their power management at kernel level. Unwary users – eg. like me – tend to neglect their meaning and use. But they are useful options though. Time to explain.

Generally there are three options with varying levels of power saving: shutdown, hibernate and suspend. To revert these there are three options again: restart, thaw and resume (of which ‘thaw’ seems to be used by developers only).

Let us have a closer look at the options.

Power saving options

Shutdown does what it says: it completely shuts down the computer. So, maximum power saving. (Although the motherboard may still be on standby power; to switch it off fully, press and hold the on/off button for 4 seconds, until you hear the harddisk stop spinning.) To get the machine going again you will need a restart – or ‘reboot’, or ‘system start’ – which will go through the full procedure from BIOS, boot loader (eg. GRUB) and X server to desktop manager (eg. KDE, GNOME, Cinnamon, Xfce etc.). Therefore, when on a running computer you click ‘Restart’, the machine will be completely shut down and then restarted from the BIOS onwards.

Hibernate also closes down the computer to standby power state, but the active system state is stored to – the swap partition of – the harddisk. For that reason hibernate is also called ‘suspend to disk’. On reactivating (the ‘thaw’ thingy) and login you will be back exactly where you left without having to go through the whole system start procedure. Reactivating may happen by opening the laptop lid, pressing the on/off button, or touching the keyboard and moving the mouse.

Suspend closes down all subsystems, but keeps memory alive, so the active system state can be kept in RAM. Consequently the precise name is ‘suspend to RAM’ – aka ‘sleep’ by those coming from the remote shores of Mac or Windows. On resume the system will be quickly reactivated from what was saved to RAM, and in a wink you are back right where you left. If you wish so you can require a login password on resume. Minor disadvantage: if for some reason the power is cut off, or the laptop’s battery runs empty, you will lose your saved machine state and need a full restart.

Here is another explanation of the difference between hibernate and suspend. And for the truly curious: Arch Wiki explains all the ins and outs of power management.

From the commandline

Now you may wish to use commandline commands to suspend or hibernate, eg. to create a keyboard shortcut for these actions. The exact commands depend on your desktop manager and even its  version. Below I give the commands for Ubuntu based systems running KDE (eg. Kubuntu or LinuxMint) to suspend and lock the screen.

Possibly you will have to install a few extras. Just test the command in a terminal and you will be told.

Up to Ubuntu 14.04 the screen can be locked by using qdbus, and suspended through dbus. The full command is:

qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock && dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend

To hibernate replace ‘Suspend’ at the end of the command by ‘Hibernate’ (mind the capitals).

If you only want to lock the screen, without suspending, you might use i3lock, but this does not present a neat login dialog on resume, so it works a bit clumsy.

On Ubuntu 16.04 the suspend command is much simpler:

systemctl suspend

To also lock the screen, go to System Settings > Desktop Behaviour > Screen Locking and on the ‘Activate’ tab check the box at ‘Lock screen on resume’.

And to hibernate, not surprisingly, type:

systemctl hibernate

Please forget about the pm-suspend or dm-tool commands. They require installing older or conflicting software.

More information (read carefully and critically!):

https://askubuntu.com/questions/1792/how-can-i-suspend-hibernate-from-command-line/919121#919121

https://forum.kde.org/viewtopic.php?f=67&t=128548

https://askubuntu.com/questions/777178/suspend-command-in-ubuntu-16-04

https://i3wm.org/i3lock/

Sleep well
Getagd op: