brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: ioreg prints your MacBook battery cycle count in the terminal

Terminal
~/tips/tip-ioreg-battery-cycle-count

ioreg -rn AppleSmartBattery | grep CycleCount

Prints the battery cycle count of a MacBook straight from the terminal.

The battery page in System Settings tells you the condition but not the cycle count. I’d use the terminal when I want the number.

Run this on a MacBook:

ioreg -rn AppleSmartBattery | grep CycleCount

ioreg prints the I/O Registry, the list of hardware the system knows about. -r shows the matching object and everything below it, -n selects it by name, and AppleSmartBattery is the battery. The grep keeps only the line with the count, which looks like "CycleCount" = 123.

Drop the grep and you see everything the battery reports, which is a long list of keys. It is worth scrolling through once to learn what is there.

A caveat: the number alone doesn’t say much. Apple publishes how many cycles each Mac model is designed for, and the battery condition in System Settings is based on more than the count. Use the count together with that, not instead of it.

If you only want the condition and the count in a friendlier layout, system_profiler SPPowerDataType prints both. On a desktop Mac there is no battery object, so the command prints nothing.

Further reading: ioreg man page overview (ss64)

More Terminal tips Terminal can save your windows and tabs as a window group Export a Terminal profile to a .terminal file and import it on another Mac mc hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x700000029}]}' sudo tmutil restore -v "/Volumes/Backup Disk/Backups.backupdb/My Mac/2026-11-30-120000/Macintosh HD – Data/Users/me/Documents/report.pdf" ~/Desktop/ All Terminal tips (116) All topics

Link