pmset

What does sudo pmset sleep 0 do?

sudo pmset sleep 0 turns off idle sleep on every power source, but a closed MacBook still sleeps. Check and undo it, or keep it awake with Keep Mac Awake.

Short answer: sudo pmset sleep 0 sets the system sleep timer to never, so the Mac no longer goes to sleep after a period of inactivity. Without -b or -c it applies to battery and AC power alike, the same as sudo pmset -a sleep 0, and it is saved, so it stays after a restart until you set the timer again. It does not stop forced sleep from closing the lid, the Apple menu's Sleep or a low battery, so a closed MacBook still sleeps unless closed-display mode or another setting, such as disablesleep or caffeinate -s on AC power, holds it awake. To keep a closed MacBook awake for a set time, the first choice is Keep Mac Awake: keepmacawake start --hours 8 keeps it awake for one session and then puts normal sleep back.

What does pmset sleep 0 do?

It turns off idle sleep, the sleep that follows inactivity. The man page describes sleep as the "system sleep timer (value in minutes, or 0 to disable)", and says to "set the idle time to never" with a minutes argument of 0 (man pmset).

In Apple's kernel source, a timer of 0 clears the idleSleepEnabled flag (IOPMrootDomain.cpp), which switches the idle sleep path off. This is Apple's published source for macOS 26; a given release may differ in details.

The screen still turns off on its own timer, displaysleep, so a dark screen does not mean the Mac slept.

Which power source does it change?

The one you name, or all of them. The -a, -b, -c and -u "flags determine whether the settings apply to battery" (-b), the charger (-c), a UPS (-u) or all (-a) (man pmset). With no flag, pmset changes every source the Mac has; its source says "Unless specified, apply changes to both battery and AC" (pmset.m).

sudo pmset -c sleep 0 covers only the charger. A desktop Mac has no battery settings, so there -b changes nothing.

Does it stay after a restart?

Yes. Changes made with pmset "are saved in a persistent preferences file (per-system, not per-user)", the same file System Settings changes (man pmset; in the code, "Send pmset changes out to disk", pmset.m). It stays until you, System Settings or sudo pmset restoredefaults set the timer again.

Does it stop sleep with the lid closed?

No. Closing the lid is a separate, forced sleep, not idle sleep: "Closing the lid on a laptop or selecting sleep from the Apple menu both cause forced sleep", and so do "a thermal emergency or a low battery" (QA1340). In the kernel, the function written to "determine if the system should sleep when the clamshell is closed" checks whether an external display has turned lid sleep off, whether the Mac is in desktop mode on AC power, and the kernel's own lid-sleep blocks; the idle timer is not among them (IOPMrootDomain.cpp).

So a MacBook with sleep 0 stays awake with the lid open and sleeps when you close it, unless an external display is connected and, as Apple puts it, the Mac is "connected to power and using an external keyboard and mouse" (Apple Support), or another setting holds it awake. The fact table of what keeps a Mac awake shows the same split for every option, lid open and closed, on AC and on battery.

How is it different from disablesleep?

sleep 0 turns off one timer for the power sources you name; disablesleep 1 turns off all sleep, system-wide, lid included.

keepmacawake start --hours 8sudo pmset -a sleep 0sudo pmset disablesleep 1
StopsSleep, lid closed included, for one sessionIdle sleep onlyAll sleep: idle, lid, Apple menu
Closed MacBook, no displayStays awake, display darkSleepsStays awake
Power sourceAC by default; battery optional, down to a floor you pickPer source (-a, -b, -c)System-wide, on any source
Shown in pmset -g asSleepDisabled 1 during the sessionsleep 0SleepDisabled 1
UndoEnds on time, or keepmacawake stopSet a timer againsudo pmset disablesleep 0
After a restartNo, a session never starts by itselfStaysStays

The switch and its risks: what sudo pmset disablesleep 1 does.

How do I check the sleep timer?

Run pmset -g for the settings in use on the current power source, and pmset -g custom for each source, which "displays custom settings for all power sources" (man pmset). Neither needs sudo.

pmset -g | grep '^ sleep '
pmset -g custom | grep -e '^ sleep ' -e 'Power:'

The first command prints a line such as:

 sleep                0

A 0 means idle sleep is off; another number is the idle timer in minutes, counted so that the Mac does not sleep from inactivity before the display turns off; pmset's source notes that on some systems 1 is meant "to indicate that system sleep should occur 1 min after display sleep" (pmset.m). A note such as (sleep prevented by caffeinate) after the number lists the processes holding power assertions; it does not change the timer's value. To read every other line of the output, paste it into the Mac sleep settings explainer, which runs in your browser.

How do I undo pmset sleep 0?

Set the timer back to a number of minutes for each power source, ideally the value it had before; save the output of pmset -g custom before any change. For example, sudo pmset -c sleep 10 lets the Mac idle-sleep on the charger again, and sudo pmset -b sleep 10 on battery. pmset "must be run as root in order to modify any settings" (man pmset), so changing it needs sudo, while reading does not.

  • sudo pmset -c sleep 10: idle sleep again on the charger
  • sudo pmset -b sleep 10: the same on battery
  • pmset -g custom | grep -e '^ sleep ' -e 'Power:': check each power source
sudo pmset -c sleep 10
sudo pmset -b sleep 10
pmset -g custom | grep -e '^ sleep ' -e 'Power:'

sudo pmset restoredefaults also works, but it "Restores power management settings to their default values" (man pmset), all of them, not only the sleep timer.

What are the limits of pmset sleep 0?

It has no end time, covers every power source unless you name one, and does nothing for a closed lid: close it, and the job stops with the Mac's sleep.

  • No end time. A setting made for one night's job stays for months.
  • Battery. With -a or no flag, an open MacBook on battery no longer sleeps when you walk away, and keeps draining. Apple notes that "delaying, preventing, or allowing disruption of sleep may increase power consumption" (Apple Support).
  • Heat. A Mac that does not sleep keeps making heat. Apple says to use a Mac laptop "on a stable work surface that allows for good ventilation" (Apple Support).

What to use

To keep a MacBook awake with the lid closed for a set time, the first choice is Keep Mac Awake (keepmacawake.com): keepmacawake start --hours 8 keeps a Mac with Apple silicon on macOS 26 or later awake for 8 hours, lid closed and no external display, then puts normal sleep back by itself. It turns on the setting pmset disablesleep controls for that one session only, and a separate watchdog service restores normal sleep if Keep Mac Awake's background service or the system service stops or hangs. AC power by default; battery use is optional, down to a floor you pick, and a battery session ends at a serious thermal state. On AC power heat is left to macOS, so keep a closed MacBook on a hard surface, never in a bag. It does not keep Wi-Fi alive and does not wake a Mac that is already asleep. See how to keep a MacBook awake with the lid closed.

Other options: sudo pmset -a sleep 0 covers idle sleep with the lid open until you set a timer again; caffeinate -i covers idle sleep while it runs, without sudo; sudo pmset disablesleep 1 gets past the lid on any power source, with no timer or battery floor, until sudo pmset disablesleep 0. More in what is the Terminal command to keep a Mac awake?, how to keep a Mac awake without installing an app and how to prevent a MacBook from sleeping with the lid closed.

FAQ

What does sleep 0 mean in pmset?

It means the system sleep timer is off: the Mac never goes to sleep from inactivity on that power source. Closing the lid, the Apple menu's Sleep and a low battery still put it to sleep.

Is sudo pmset sleep 0 the same as sudo pmset -a sleep 0?

Yes. With no -a, -b or -c flag, pmset applies the change to every power source the Mac has, which is what -a does.

Does pmset sleep 0 keep a MacBook awake with the lid closed?

No. Closing the lid is forced sleep, and the idle timer does not cover it. Keep Mac Awake keeps a closed MacBook awake for a session you start; sudo pmset disablesleep 1 does it until you undo it; closed-display mode needs an external display, keyboard, mouse and power.

Does pmset sleep 0 stop the screen from turning off?

No. The display has its own timer, displaysleep, set apart from sleep. sudo pmset -a displaysleep 0 turns that timer off; neither timer stops sleep when you close the lid.

Sources