These are mostly things which I cannot remember, or which I just want to have handy for copying and pasting. 

DNS

Flushing the DNS Cache

dscacheutil -flushcache; sudo killall -HUP mDNSResponder

Show DNS Config

Displaying the current resolver configuration
scutil --dns

 

Finding the last Wireless AP and SSID that a Mac connected to:

log show --predicate '(processImagePath contains "configd") && (eventMessage contains "en0: SSID ")' --style syslog --last 1d

 

KTrace / Strace equivilent

sudo ktrace trace -S -f C3,C4 -s -c <command>

 

See what is keeping MacOS awake

pmset -g assertions

 

See what files a process is using / accessing:

sudo fs_usage pid <pid>

 

A less awful way of looking at logs

log stream --predicate 'process contains "kernel"' --debug --info --style compact

log stream --predicate 'subsystem == "com.apple.network"' --debug --info --style compact

 

The “Mac Framework” way of fetching content.

nscurl

 

Stopping Mac powering on when lid opens

  • Don't turn on when opening lid, or connecting to power: sudo nvram BootPreference=%00
  • Don't turn on when opening lid: sudo nvram BootPreference=%01
  • Dont torn on when connecting to power: sudo nvram BootPreference=%02