How can I suspend or hibernate my laptop using command line, without installing additional software?

- 105,154
- 20
- 279
- 497

- 4,933
14 Answers
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. This new method doesn't require root and notifies all applications listening for power events.
Systemd Method
Starting with Ubuntu 16.04, systemctl
call must be used (See Suspend command in Ubuntu 16.04)
systemctl suspend
and
systemctl hibernate
New Method (obsolete)
Obsolete circa Ubuntu 16.04; use systemctl
instead, as above.
See the answer here on this page from Adam Paetznick regarding the use of dbus. Ideally you would create a ~/bin/suspend
shortcut/script that makes the use of this action easy.
For use over ssh, you should modify policykit rules as outlined by Peter V. Mørch
Old Method
According to the Ubuntu Forum you can use the following commands:
pmi action suspend
and
pmi action hibernate
This requires that you install the powermanagement-interface package (not tested).
sudo apt-get install powermanagement-interface
I have also found the commands sudo pm-suspend
and sudo pm-hibernate
to work on my netbook.

- 552

- 28,462
-
26pm-suspend and pm-hibernate works for me and it's easy. Requires sudo but that's OK.
(Found pmi idea before but installing a package to use suspend is well bad...) – user1034 Aug 09 '10 at 20:52 -
-
1Note that you have to
apt-get install powermanagement-interface
to run pmi. – nealmcb Feb 10 '12 at 01:47 -
1
-
1doesn't work with my ubuntu 12.10. after
apt-get install powermanagement-interface
– somethis Jun 02 '13 at 09:37 -
1new method is now broken see http://unix.stackexchange.com/questions/153099/debian-jessie-cannot-suspend-anymore – ijk Apr 03 '15 at 18:28
-
-
sudo pm-suspend
works well but while waking up after doing so doesn't ask me for password. what should I do. – Jaysheel Utekar Sep 10 '15 at 07:18 -
1none of the above works, even with sudo rights. not the
pm-hibernate
,pmi action hibernate
, not thedbus
stuff. I am sad. – phil294 Mar 18 '16 at 01:22 -
I'm on 16.04 and both
systemctl suspend
andpm-suspend
work; the difference being that the latter does not first lock the screen and requiressudo
to run. – Alan Plum Feb 05 '17 at 13:42 -
-
2
-
1
systemctl suspend
worked for me on Ubuntu 20.04, although it made me type my password twice. – Ryan Jun 20 '21 at 23:20 -
systemctl hibernate
doesn't work for me. I have Ubuntu 18.04.5 LTS on Lenovo-Z50-70. – Abdollah Sep 22 '21 at 07:06 -
Doesn't work on my 21.10 OS. Even when root, and executed locally:
Unit suspend.target is masked.
– Bram Dec 08 '21 at 17:17 -
systemctl hibernate
worked for me inUbuntu 18.04.1 LTS
BUT, while hibernating, the screen seemed to freeze, and also the fans when turning it on where insanely loud for at least 10 seconds... I am not sure why. – M.K Feb 23 '22 at 08:53 -
Both of
systemctl suspend
andsystemctl hibernate
work well on my Ubuntu 14.04 LTS – Ham Feb 28 '22 at 14:39 -
Why the
Systemd Method
header when the method issystemctl
instead? They are not the same. Perhaps still good to have that header for search hits, though. – questionto42 Mar 25 '22 at 23:17 -
1This answer get confusing at section 3: the new obsolete section. Is the new method obsolete? – ctrl-alt-delor Aug 30 '22 at 08:17
-
I had to use
sudo
, as in:sudo systemctl suspend
for it to work. – Gabriel Staples Sep 11 '23 at 00:33 -
Any idea how
sudo systemctl suspend
differs from mysudo true && gnome-screensaver-command -l && sudo pm-suspend
command in my answer? Do they have any different side effects or nuances you are aware of? – Gabriel Staples Sep 11 '23 at 00:37
The gnome-friendly way is to use dbus.
dbus-send --system --print-reply \
--dest="org.freedesktop.UPower" \
/org/freedesktop/UPower \
org.freedesktop.UPower.Suspend
There are two advantages to this command over pm-suspend
.
It will lock your screen (upon resume) if you have that option selected in gnome.
It does not require root privilege, so it is easy to add it as a keyboard shortcut, for example.
As mentioned in the comments exchanging the Suspend
in the last line to Hibernate
creates a hibernate command:
dbus-send --system --print-reply \
--dest="org.freedesktop.UPower" \
/org/freedesktop/UPower \
org.freedesktop.UPower.Hibernate
If the hibernation throws Error org.freedesktop.UPower.GeneralError: not authorized
your user might not be allowed to hibernate. Edit or create /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
so it contains the following section: (source)
[Re-enable hibernate by default]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes
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.

- 103

- 2,408
- 2
- 16
- 13
-
18Your answer really should be first. It's non-root no-packages-to-be-installed gnome way of doing it. Like! – turbo Jun 07 '12 at 16:26
-
1
-
1AFAIK there is another advantage: It allows other program to detect that suspend/resume happened and act accordingly (for example an IM to resume a network connection to a server). – Petr Dec 06 '12 at 21:24
-
While this is actually the right way to do it (tm), SSH users should take note of : http://askubuntu.com/questions/21586/how-can-i-configure-dbus-to-allow-ssh-user-to-suspend-server – airtonix Jul 30 '13 at 00:52
-
12To
Hibernate
, you can simply replace the last line withorg.freedesktop.UPower.Hibernate
– Sheharyar Aug 11 '13 at 08:46 -
This works under KDE too, except it doesn't lock the screen. You can do that with
qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock
. – Mechanical snail Nov 14 '13 at 10:14 -
Under 13.10 I get
Error org.freedesktop.UPower.GeneralError: not authorized
– Patryk Dec 28 '13 at 01:24 -
2on my 13.10 it does work. however, the screen is not locked upon resume, even though in "Security and Privacy", "Require my password when waking from Suspend" is activated. – andreas-h Feb 22 '14 at 12:24
-
1This may be gnome friendly but I can still tell (i.e. wifi/ethernet notification and no graphic glitch) it's not the same clean result than when I do it through the Unity GUI or in the case of my laptop through a hardware suspend button. – sinekonata Apr 16 '14 at 19:38
-
6Didn't work for me (Gnome 3.12, Ubuntu 14.04). Seems the [UPower.Suspend] interface was removed, according to https://bugs.launchpad.net/ubuntu/+source/gnome-power-manager/+bug/554899 – Gui Ambros May 25 '14 at 14:09
-
7Suspend interface was moved to logind; http://askubuntu.com/questions/652978/ – Khurshid Alam Aug 06 '15 at 07:52
-
This did work for me under 14.04 Trusty, but just moved to 15.10 Wily and it no longer works. – Gringo Suave Nov 18 '15 at 17:57
-
firstly, screen locking is not done, and secondly, after each hibernate-resume, the wifi laggs about every other minute. totally unusable for me. – phil294 Mar 18 '16 at 00:24
-
1Please evaluate if this gnome-friendly method is not superceded by 'the new command of systemd' as indicated in (https://askubuntu.com/questions/777178/suspend-command-in-ubuntu-16-04) – Tfb9 Jun 19 '17 at 22:36
-
1
-
Error org.freedesktop.DBus.Error.UnknownMethod: No such method “Suspend”
KDE on Debian GNU/Linux 11 (bullseye) – ctrl-alt-delor Aug 30 '22 at 08:24
If you want your computer to suspend in one hour because you want to go to bed listening to your favorite radio station, open the terminal and type:
sudo bash -c "sleep 1h; pm-suspend"
and your computer will fall asleep in 1 hour. When you awake, it 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.

- 15,657

- 695
-
That's my use case I'm looking for! AFIK pm-* can be run without superuser permissions – ruX Jul 28 '14 at 22:49
-
1evidently, this solution needs the
pm-utils
suite:apt-get install -y pm-utils
:-) – Steve Baroti Jun 28 '21 at 05:02
To get Hibernation:
sudo pm-hibernate
To get Suspend:
sudo pm-suspend

- 102,391
- 106
- 255
- 328
-
-
Yeah I think that package was not installed . look for those packages in synaptic. – Raja G Nov 23 '12 at 17:34
-
the package is installed, I think 'mate-power-manager' is interfering with it. – rsjethani Nov 23 '12 at 20:22
-
Perfect, thanks the pm-suspend was exactly what I was after without having to install all the X related junk with the powermanagement-interface package. All that's needed to use pm-* is the the pm-utils package. – Maks Oct 22 '14 at 10:05
-
2The drawback of this method is that if you are using the GUI, pm-suspend will NOT block your session, which can be insecure. – Raúl Salinas-Monteagudo Feb 18 '15 at 12:48
-
1
-
1
-
-
Recent debian today (2024), I believe pm-suspend is the best what we have. – peterh Jan 01 '24 at 12:42
You can use the file /sys/power/state
to do this. First find out what states are supported:
user@linux:_> cat /sys/power/state
standby mem disk
root@linux:~> echo -n mem > /sys/power/state # suspend to ram
root@linux:~> echo -n disk > /sys/power/state # suspend to disk
or via dbus:
#Hibernate
dbus-send --session --dest=org.gnome.PowerManager \
--type=method_call --print-reply --reply-timeout=2000 \
/org/gnome/PowerManager org.gnome.PowerManager.Hibernate
According to this entry in launchpad the above interface was removed. So it would not work anymore in Ubuntu.

- 19,125
-
First idea gives me: "bash: echo: write error: Invalid argument"
Dbus idea gives output: "Error org.freedesktop.DBus.Error.UnknownMethod: Method "Suspend" with signature "" on interface "org.gnome.PowerManager" doesn't exist"
– user1034 Aug 09 '10 at 20:58 -
I added a small explanation to the
/sys/power/state
-thing. Furthermore the dbus method was removed from Ubuntu so it won't work anymore. – qbi Aug 09 '10 at 21:45 -
$ sudo echo -n mem > /sys/power/state
-bash: /sys/power/state: Permission denied
– Hubro Aug 24 '14 at 21:01 -
6This works great. For people having problems with this method when using sudo, the "pipe to file", aka ">" is running in your current shell, so it doesn't get super user privileges while your echo did. You'll need to use
sudo -i
first, or pipe tosudo tee
like so:echo mem | sudo tee /sys/power/state
– RandomInsano Sep 01 '14 at 04:22
since 15.04 systemD is the standard init system so there is a new command to be used:
systemctl suspend

- 414
-
I'm using Xubuntu 15.04. The command
systemctl suspend
does suspend the computer, but it does not cause the screen to be locked, even though I've checked the "Lock screen when system is going for sleep" checkbox in Settings -> Power Manager -> Security. Anyone have any idea why? – Teemu Leisti Apr 10 '16 at 13:28 -
I've upgraded to Xubuntu 16.04. The command
systemctl suspend
still suspends the computer. Now, it also causes the screen to be locked, if and only if the "Lock screen when system is going for sleep" checkbox in Settings -> Power Manager -> Security is checked. – Teemu Leisti Jun 22 '16 at 18:54
To suspend a system (14.04) from the command line (or keyboard shortcut) use:
dbus-send --system --print-reply --dest="org.freedesktop.login1" /org/freedesktop/login1 org.freedesktop.login1.Manager.Suspend boolean:true
I found this out by playing around with gdbus which can list the interfaces available:
To list the services available on the bus:
dbus-send --system --dest=org.freedesktop.DBus --type=method_call --print-reply /org/freedesktop/DBus org.freedesktop.DBus.ListNames
To find the methods:
gdbus introspect --system --dest org.freedesktop.login1 --object-path /org/freedesktop/login1 --recurse

- 5,600

- 300
- 1
- 3
- 9
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:
$ gnome-screensaver-command --lock && pmi action hibernate
I imagine this does not depend on the gnome configuration, but I haven't tested that.
-
Nice. Or
xscreensaver-command --lock
as the case may be. – Tim has moved to Codidact Mar 04 '17 at 01:49
New interface
…which works in 15.10 Wily, and possibly Utopic and Vivid.
dbus-send --print-reply --system \
--dest=org.freedesktop.login1 \
/org/freedesktop/login1 \
org.freedesktop.login1.Manager.Suspend boolean:true
Helpfully this doesn't require sudo, unlike the pm-suspend
command.

- 736
-
My XPS 13 9350 with Debian/Gnome was with suspend/hibernate issues when closing the lid. After running this command (and the equivalent for hibernation), it went successfully into suspension (and hibernation) and now closing and opening the lid work as expected! – Victor Schröder Dec 25 '16 at 18:29
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) &"' x@192.168.1.4'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.

- 181
- 1
- 3
The following works for me on 16.04 (with Gnome desktop):
gnome-screensaver-command --lock && compsleep
I have also installed it as a custom keyboard shortcut via the Gnome settings panel as keys "Shift-Super-X".

- 219
- 4
- 6
How to lock the screen and put the computer to sleep (suspend) in a 1-liner from the command line (could be assigned to an Ubuntu shortcut key)
Tested on Ubuntu 22.04.
This is directly from my longer answer here. Refer to that answer for a detailed explanation of this command:
You can lock the screen and put the computer to sleep in a single command like this:
# lock the screen and put the computer to sleep sudo true && gnome-screensaver-command -l && sudo pm-suspend
You can assign the above command to a shortcut key if you want to quickly put your computer to sleep.
sudo systemctl suspend
, as shown in the main answer, also seems to produce a similar result to my sudo true && gnome-screensaver-command -l && sudo pm-suspend
command. I don't know how they differ or if they have any different effects.
Update: on older versions of Ubuntu, it's possible that sudo systemctl suspend
will not also lock the screen and require a password upon waking up, whereas my sudo true && gnome-screensaver-command -l && sudo pm-suspend
command will always lock the screen first and require a password after wake-up. On Ubuntu 22.04 though, the results seem to be the same. In the Edge Browser only (using any other browser won't show the full content), you can see a chat I had with Bing AI about this here.
After waking up from sleep (suspend), you can run journalctl -n 1000 -e | grep "PM: suspend"
to prove your computer really was asleep. Again, see my longer answer on this for details.
Via the GUI menus:
Running my command above produces the exact same result as clicking the top-right of your screen and going to "Power Off/Log Out" --> Suspend, as shown in this screenshot here:

- 9,155
Personally, I've been experimenting with the pmi method. However, when I tried this, I got an error message: Error org.freedesktop.DBus.Error.Spawn.ChildExited: Launch helper exited with unknown return code 1
. However, there is a workaround in the 3rd comment of this bug report, which seems to have worked for me (I'm using Ubuntu 13.03).

- 1,444
- 2
- 15
- 19
-
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – fossfreedom Aug 31 '13 at 07:37
Update for those who, like me, still work on KDE/Ubuntu 14.04 systems. To lock use qdbus
, and to suspend use dbus
. Full command:
qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock && dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
To hibernate, i.e. suspend to harddisk instead of RAM, replace 'Suspend' at the end of the command by 'Hibernate'.
To just lock the screen without suspending, xscreensaver-command -lock
will work, IF you type only 1 hyphen for the '-lock' option, and only if the screensaver is running. Actually not a very useful command. Using i3lock
is easier, but then you will not get a neat login dialog to get back to work, as you will when using qdbus
.

- 71
systemctl suspend
– CJlano Jun 22 '16 at 07:05