How can I suspend or hibernate my laptop using command line, without installing additional software?
Traditionally ubuntu supported a fairly blunt method of suspend and hibernate. Neither would integrate well with other apps and sometimes not even work on some machines. The new method doesn't require root and notifies all applications listening for power events.
See the answer here on this page from Adam Paetznick regarding the use of dbus. Ideally you would create a
For use over ssh, you should modify policykit rules as outlined by Peter V. Mørch
According to the Ubuntu Forum you can use the following commands:
This requires that you install the powermanagement-interface package (not tested).
I have also found the commands
The gnome-friendly way is to use dbus.
There are two advantages to this command over
As mentioned in the comments exchanging the
If the hibernation throws
This was tested on UbuntuGnome 14.04.
Note: This is basically the same as qbi's answer, but updated to work for newer versions of Ubuntu as well as including hibernate.
If you just want your computer to suspend in one hour because you want to go to bed listening to your favorite radio station, just open terminal and type :
and your computer will fall asleep in 1 hour, and when you awake, he will have kept your open images and all your stuff.
you can replace 1h by what you want (¨h¨ for hours, ¨m¨ for minutes, ¨s¨ for seconds, ¨d¨ for days).
Si vous voulez juste que votre ordinateur se mette en veille dans une heure parce que vous voulez vous endormir en ecoutant votre radio préférée, ouvrez Terminal et tapez :
et votre ordinateur s´endormira dans une heure, et quand vous vous réveillerez, il aura conservé en mémoire vos applications ouvertes.
Vous pouvez remplacer 1h par ce que vous voulez (¨h¨ pour les heures, ¨m¨ pour les minutes, ¨s¨ pour les secondes, ¨d¨ pour les jours).
For Ubuntu 12.04 LTS & Ubuntu 13.04
To get Hibernation
To get Suspend
You can use the file
or via dbus:
According to this entry in launchpad the above interface was removed. So it would not work anymore in Ubuntu.
Adam Paetznick's dbus-send answer didn't work as purported for me on lucid; the machine woke up unlocked, even though the gnome-power-manager is set to lock the screen on wake-up. I want the screen to be locked at wake-up, and found that the following does that:
I imagine this does not depend on the gnome configuration, but I haven't tested that.
To shutdown a system (14.04) from the command line (or keyboard shortcut) use:
I found this out by playing around with gdbus which can list the interfaces available:
To list the services available on the bus:
To find the methods:
Personally, I've been experimenting with the pmi method. However, when I tried this, I got an error message:
Here's how to put a remote machine in standby over ssh:
ssh -t 192.168.1.4 'sudo nohup &>/dev/null bash -c "(sleep 1; echo -n mem >/sys/power/state) &"' firstname.lastname@example.org's password: [sudo] password for x: Connection to 192.168.1.4 closed.
/sys/power/state works in Ubuntu 13.10. pmi gives Dbus error.
protected by Raja Aug 11 '14 at 10:35
Thank you for your interest in this question.
Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.
Would you like to answer one of these unanswered questions instead?