This page has affiliate links
NordVPN

All new RAW Mac posts are on rawinfopages.co.uk

Change Apple Mac sleep settings from Terminal command prompt

Apple MacBook laptop computer on a table in sleep mode

There is more to sleep mode on the Apple Mac than you might think and there are hidden settings, different modes and keyboard shortcuts. Here is everything you need to know.

Go to the Apple menu on your Mac and there is an option to put the Mac to sleep. It looks like it shuts down the Mac, but it actually turns off the screen and switches to a low power consumption mode. It is still running, but only just enough so it does not lose whatever is running. This means that it can then be quickly woken so that you can carry on working in a couple of seconds, rather than waiting up to a minute for a normal boot up from cold.

MacBook owners have another way to put their laptop to sleep and this is by simply closing the lid. Old MacBooks used to have a flashing LED to show that they are in sleep mode and it is a shame modern Macs don't have this. Open the lid and the MacBook wakes up.

Another way to put the Mac to sleep is to press Command+Option+Power button. However, it is easy to muddle this up with other commands like Command+Ctrl+Power button, which forces the Mac to restart. Be careful or you might loose your work in open apps.

What you may not be aware of is that iMacs and MacBooks use different sleep modes. An iMac uses sleep mode 0 and a MacBook uses sleep mode 3. There is another sleep mode, 25, that is not used by any Macs, but you can set it if you want to. You can also use the iMac sleep mode on a MacBook and MacBook sleep mode on an iMac.

It all sounds very confusing, but really it is quite straightforward.

Sleep mode 0

This is the default setting on desktop Macs and in this mode the computer is put into a low power state. The screen is turned off, sinning disks stop spinning (if it has one), the CPU slows right down and so on. Every component runs in its lowest power mode and they are barely functioning, but it is sufficient to maintain the contents of memory. When you press a key, the Mac wakes up all the components, which resume their normal power state. You can then continue working exactly where you left off.

This mode is used by desktop Macs because they are plugged into the mains power and this is assumed to be stable and permanently available. If sleep mode 0 were to be used on a MacBook, sooner or later the battery would drain and eventually power would be lost, the contents of memory would be lost, and so would every app you were using.

Sleep mode 0 is the fastest sleep mode. It is quickest to enter and quickest to resume. If you are sure your MacBook battery will not completely run down, setting sleep mode 0 will be faster than normal sleep mode. As long as you wake it up before the battery dies, you will be OK.

Sleep mode 3

This sleep mode is designed to get around the problem of the battery draining and you losing all your work in any applications that are open. When a MacBook goes into sleep mode, it saves the current computer state to the disk. That is everything in memory, the apps you are using, the windows that are open and the documents being edited.

Once this disk backup has been made, which adds several seconds to the process, the MacBook then goes into sleep mode like an iMac. As long as there is battery power, the MacBook can instantly resume.

If the battery runs out and the MacBook loses power, you can plug in the power cable and start the Mac by pressing the power button as usual. It will resume from sleep mode by loading everything from disk. The exact computer state is restored from the backup and you can carry on where you left off. Restoring that disk backup takes a lot longer than resuming from memory. It works, but it is very slow in comparison.

Suppose you live in an area where the mains power is unstable. A mains-powered desktop Mac could lose power while in sleep mode and you could lose your work in any open applications. Sleep mode 3 would be better in this case because it saves a backup to disk. If the power is cut, the iMac will resume from sleep when power is restored by loading the disk backup.

One disadvantage of sleep mode 3 is that a file on disk the same size as the RAM in the iMac or MacBook is created. So if you have a lot of RAM, then a lot of disk space is consumed in sleep mode 3. That could be inconvenient if the Mac has a small SSD.

Sleep mode 25

This starts off like sleep mode 3 and the current computer state is saved to the disk drive. The iMac or MacBook then shuts down and powers off. When you resume from sleep by pressing the power button, it reloads everything from disk and lets you carry on where you left off.

Saving memory to disk uses disk space and is slow. Restoring everything from disk is also slow. The advantage for MacBook users though, is that no battery power is required during sleep mode because the computer is switched off. The MacBook could sleep for a week or a month, you could switch back on and carry on exactly where you left off.

Set the sleep mode

The way to set these three sleep modes is by entering commands at the Terminal command prompt. Go to the Applications folder, open the Utilities folder and run Terminal.app.

At the command prompt, enter one of the following commands:

sudo pmset -a hibernatemode 0
sudo pmset -a hibernatemode 3
sudo pmset -a hibernatemode 25

Choose the best mode bearing in mind the pros and cons described above. The sudo at the start of each line is required and is basically admin mode, which requires you to enter your password. The pmset is the actual power management command. The -a means the setting applies to all power modes (battery, mains power etc.) and substituting -b or -c applies the sleep mode to just battery or charger (mains power). Finally, hibernatemode 0, 3, 25 is the power mode to use. Don’t try any other numbers, these are the only three you should use.

More power managemant commands

There are many power management command, well, one command and lots of parameters. We used pmset to set the sleep mode. It can also be used to determine whether a MacBook wakes when the lid is opened:

sudo pmset lidwake 0 (don't wake)
sudo pmset lidwake 1 (wake)

To instantly put the Mac into sleep mode from the command prompt or to just put the display to sleep, use these commands:

pmset sleepnow
pmset displaysleepnow

No need for sudo this time because no system settings are changed.

To see a list of all the power management settings, the battery settings and mains power settings, enter:

pmset -g
pmset -g batt
pmset -g ac

This is not a complete list of commands, just the main ones. There are many more, but they are not ones you need everyday. For example, you could specify that the system sleep on a specific date and time in the future. You could even set your Mac to hibernate when Winter comes. Sounds like a good idea for people, never mind computers.

Related: How to customise the power settings from Terminal on the Mac

Affiliate links
CleanMyMac X