Hibernate from Terminal

To hibernate from terminal you must use the pmset command. However, pmset only allows you to set the hibernate mode. It does not immediately put your machine to sleep. An example:

sudo pmset -a hibernatemode 25

There are 4 power management options:

  1. -b  —  Battery
  2. -c  —  Charger
  3. -u  —  UPS
  4. -a  —  All of the above

There are a total of 7 hibernation modes. The first 3 modes are standard. The last 4 modes may be used, though they are NOT recommended (as per the pmset man page):

  1. hibernatemode 0 — The system will not back memory up to persistent storage. The system must wake from the contents of memory; the system will lose context on power loss. This is, historically, plain old sleep. In binary, 0000 0000.
  2. hibernatemode 3 —  by default on supported portables. The system will store a copy of memory to persistent storage (the disk), and will power memory during sleep. The system will wake from memory, unless a power loss forces it to restore from disk image. In binary, 0000 0011.
  3. hibernatemode 25 — The system will store a copy of memory to persistent storage (the disk), and will remove power to memory. The system will restore from disk image. If you want “hibernation” – slower sleeps, slower wakes, and better battery life, you should use this setting. In binary, 0001 1001.
  4. hibernatemode 1 — Enables hibernation; causes OS X to write memory state to hibernation image at sleep time. On wake (without bit 1 set) OS X will resume from the hibernation image. Bit 0 set (without bit 1 set) causes OS X to write memory state and immediately hibernate at sleep time. In binary, 0000 0001 (bit 0).
  5. hibernatemode 2 — Causes OS X to maintain system state in memory and leave system power on until battery level drops below a near empty threshold (This enables quicker wakeup from memory while battery power is available). Upon nearly emptying the battery, OS X shuts off all system power and hibernates; on wake the system will resume from hibernation image, not from memory. In binary, 0000 0010 (bit 1 in conjunction with bit 0).
  6. hibernatemode 8 — Encourages the dynamic pager to page out inactive pages prior to hibernation, for a smaller memory footprint. In binary, 0000 1000 (bit 3).
  7. hibernatemode 16 — Encourages the dynamic pager to page out more aggressively prior to hibernation, for a smaller memory footprint. In binary, 0001 0000 (bit 4).

I’ve listed the binary because the command can be executed using the binary instead, which may be easier to remember for the last four options.

Option 5 is a very practical alternative and may be the way apps such as SmartSleep function (Read about SmartSleep in a previous post). However, when I set my SmartSleep setting to to “smart sleep” and then check my hibernate mode using pmset -g, the mode still reads as “0”. At any rate, the concept is similar, if not the same.

To make hibernate mode setting a bit easier to remember, I’ve added the following aliases to my .profile that I can execute on the command line:

alias hibernate='sudo pmset -a hibernatemode 25'
alias sleep='sudo pmset -a hibernatemode 0'
alias safesleep='sudo pmset -a hibernatemode 3'
alias smartsleep='sudo pmset -a hibernatemode 2'

Now I can easily how my system responds when I close my MacBook lid.

There is one final caveat: if you have an app like SmartSleep installed, it will override any hibernate mode settings you make. In testing this, I noticed how I would set hibernatemode 25 and SmartSleep to “smart sleep,” and then when I woke my machine up hibernatemode was set to “0”. Strange, but true.


  1. My favorite sleeping tweak is ‘sudo pmset lidwake 0’, so your MacBook doesn’t automatically awake from sleep when you open the lid.


  2. I’m reading and testing several times over and over but I still don’t understand what’s the difference between hibernatemode 1 and 25. Can somebody explain please?


    1. These values can be combined by XORing the binary equivalents. Hibernatemode 1 is just saying that hibernation is possible, so ANY value passed to hibernate mode with bit 0 set (hibernatemode 1) will allow hibernation.
      Doing binary XOR addition, that all just means that hibernatemode 25 (binary 0001 1001) is just hibernatemode 1 (0000 0001) + hibernatemode 8 (0000 1000) + hibernatemode 16 (0001 0000).
      In binary, the addition looks like this:
      0000 0001 (i.e., 1)
      0000 1000 (i.e., 8)
      0001 0000 + (i.e., 16)
      0001 1001 (i.e., 25)

      So essentially any value passed to hibernatemode that is odd will allow hibernation, and any value that is even will not.


Comments, questions and feedback welcome.

This site uses Akismet to reduce spam. Learn how your comment data is processed.