UPower for regular users
Major desktop environments usually provide a user-friendly menu to suspend your computer. Internally, if seems to use something called UPower, which uses something called PolicyKit, which in turn may or may not use another piece called ConsoleKit (do not ask me what all these pieces are and how they relate to each other, I do not know and I do not want to know). For the regular user, the result is the following: when they click on that button, it suspends their computer.
UPower for command line users
However, if you are using a more unusual desktop environment, for instance a simple, light window manager, you will not have such a button. And no, UPower does not provide a simple command line tool to suspend your computer¹ (they probably consider that command line is out of fashion…). Well, in case you need it, here is a way to suspend your computer from a command line or whatever: just alias it or bind it to a key shortcut. It uses some dark DBus magic:
$ dbus-send --system --print-reply --dest='org.freedesktop.UPower' \ /org/freedesktop/UPower org.freedesktop.UPower.Suspend
If you prefer to hibernate your computer, that is, to suspend it, not to RAM but to disk:
$ dbus-send --system --print-reply --dest='org.freedesktop.UPower' \ /org/freedesktop/UPower org.freedesktop.UPower.Hibernate
As you can see, for some reason it requires some duplication of information: the name “org.freedesktop.UPower” appears three times in that command line: in the “destination”, “object path” and “interface member”, whatever that could mean. Again, do not ask me why, I know nothing about that and I do not want to.
- Actually, UPower does provide a command line tool called upower, but the only thing it does (monitoring power sources) is not really useful for that matter. ↑