Linux Command: Put Laptop / Netbook In Hibernate / Suspend Mode

How do I suspend or hibernate from bash shell command line under Linux operating systems? How do I suspend or hibernate my Ubuntu Dell laptop using command line, without using additional software?

You can use the following commands under Linux to suspend or Hibernate Linux system:

  1. systemctl suspend Command – Use systemd to suspend/hibernate from command line on Linux.
  2. pm-suspend Command – During suspend most devices are shutdown, and system state is saved in RAM. The system still requires power in this state. Most modern systems require 3 to 5 seconds to enter and leave suspend, and most laptops can stay in suspend mode for 1 to 3 days before exhausting their battery.
  3. pm-hibernate Command – During hibernate the system is fully powered off, and system state is saved to disk. The system does not require power, and can stay in hibernate mode indefinitely. Most modern systems require 15 to 45 seconds to enter and leave hibernate, and entering and leaving hibernate takes longer when you have more memory.
  4. pm-suspend-hybrid Command – Hybrid-suspend is the process where the system does everything it needs to hibernate, but suspends instead of shutting down. This means that your computer can wake up quicker than for normal hibernation if you do not run out of power, and you can resume even if you run out of power.

The above commands are part of the package called pm-utils. It is a package of power management software under RHEL, Fedora, CentOS, Red Hat Enterprise Linux, Debian, Ubuntu and other Linux distros.

Linux Command: Put Laptop / Netbook In Hibernate / Suspend Mode

Let us see all commands step-by-step to put Linux laptop in hibernate or suspend mode.

Systemd based method to suspend or hibernate your Linux laptop using command line

Type the following command:
$ systemctl suspend
Sample outputs:

Fig.01: systemctl suspend to suspend Ubuntu Linux Laptop

Fig.01: systemctl suspend to suspend Ubuntu Linux Laptop

Type the following to hibernate Linux based laptop:
$ systemctl hibernate

Linux Command To Suspend System

To suspend system, enter:
# pm-suspend
$ sudo pm-suspend

Linux Command To Hibernate System

To hibernate system, enter:
# pm-hibernate
$ sudo pm-hibernate
$ systemctl hibernate

How Do I Put My Computer To Sleep After a Certain Amount Of Time?

You can use the at command as follows to put laptop to sleep after 30 minutes of time:

echo 'pm-suspend' | at now + 30 minutes


echo 'systemctl suspend' | at now + 30 minutes

How Do I Add Hooks (or so called scripts) When My System Is Suspended?

You can place your scripts in following directory. They are executed at suspend and resume:

  • /etc/pm/sleep.d – Almost all distro including Debian looks here first to run script.
  • /usr/lib/pm-utils/sleep.d – Default Debian location.

In short, if you need to run custom commands when suspending/resuming, you should place your custom scripts to /etc/pm/sleep.d/ directory only.

Sample Shell Script

# If we are running NetworkManager, tell it we are going to sleep.
# TODO: Make NetworkManager smarter about how to handle sleep/resume
#       If we are asleep for less time than it takes for TCP to reset a
#       connection, and we are assigned the same IP on resume, we should
#       not break established connections.  Apple can do this, and it is
#       rather nifty.
	# Tell NetworkManager to shut down networking
	dbus_send --print-reply --system                         \
		--dest=org.freedesktop.NetworkManager  \
		/org/freedesktop/NetworkManager        \
		org.freedesktop.NetworkManager.sleep 2>&1 > /dev/null
	# Wake up NetworkManager and make it do a new connection
	dbus_send --print-reply --system                        \
		--dest=org.freedesktop.NetworkManager \
		/org/freedesktop/NetworkManager       \
		org.freedesktop.NetworkManager.wake 2>&1 > /dev/null
case "$1" in
	*) exit $NA

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 9 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
9 comments… add one
  • Poseidon Jun 11, 2011 @ 16:40

    You can do this directly through the kernel:
    echo mem | sudo tee /sys/power/state

    which cuts down on unnecessary packages.

    Incidentally, this also works on android phones.

    • Vincent Mar 27, 2017 @ 15:40

      Doesn’t seem to work on Debian:

      # echo mem | tee /sys/power/state
      tee: /sys/power/state: Invalid argument

      • Vincent Mar 27, 2017 @ 15:47

        Here it is:

        1. Check what modes are supported:
        # cat /sys/power/state
        freeze standby disk

        2. Put computer in suspend mode:
        echo -n standby > /sys/power/state

  • beyes Jan 4, 2012 @ 5:30

    thanks very much!

  • David May 20, 2012 @ 5:33

    This works GREAT! Thank you!


  • lol Jan 9, 2013 @ 18:33

    hey, i’m still a noob to linux but i love it already. The point is, i’m currently working on a linux script. that uses ssh to control multiple computers. I want my script to be capable of putting computers to sleep (rtcwake, pm-suspend) but also to be capacle of waking him up whenever he wants . Let’s say i orderd him to sleep 30 minutes but i need him in 5, i want to be capable of waking him up from command. How do i do that?

  • martin May 6, 2014 @ 15:24

    “pm-suspend” work, but after I wake up notebook I see desktop directly without password prompt.
    How can I supend notebook with screen lock like in gnome?

    • chaanakya Jun 7, 2016 @ 2:28

      You can add a hook in /etc/pm/sleep.d/ that invokes xscreensaver or gnome-screensaver or whatever your screensaver program is. For example, I use slock, so I could invoke slock on sleep, which would lock the computer when I put it to sleep.

      Hope that helps!

  • Zacharias Voulgaris May 19, 2016 @ 20:03

    Thank you sir! These are very handy commands for bash scripts.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum