mac OS - pdorobisz/cheatsheets GitHub Wiki
Log files locations:
- System Log Folder: /var/log
- System Log: /var/log/system.log
- Mac Analytics Data: /var/log/DiagnosticMessages
- System Application Logs: /Library/Logs
- System Reports: /Library/Logs/DiagnosticReports
- User Application Logs: ~/Library/Logs
- User Reports: ~/Library/Logs/DiagnosticReports
Console is the app to view logs.
Create /etc/resolver/mydomain
file:
domain mydomain
nameserver MYDOMAIN_NAMESERVER
Clean DNS cache:
sudo killall -HUP mDNSResponder
Don't use dig
/host
/nslookup
for testing how OS uses DNS servers as they don't use system's resolver. You should rather use dscacheutil
(dscacheutil -q host -a name example.com
) or simply ping
.
- SBC - standard codec, supported by all devices, lower quality audio
- aptX - high quality audio codec, used on Android
- ACC - high quality audio codec, used on iOS devices
Using Bluetooth Explorer
Download Additional Tools for Xcode 11.4 (later versions don't have Bluetooth Explorer) and run Bluetooth Explorer. Select Tools > Audio Graphs... and play some music to bluetooth device. Active Audio Codec at the bottom left will show which codec is used.
Power management is done by System Preferences > Energy Saver
but advanced power management settings can be manipulated only by pmset
command line tool. All changes made through pmset
are done per-system, not per-user so it must be run as root in order to modify any settings.
pmset -g # current settings
pmset -g custom # settings for all power sources
pmset -g pslog # power source (e.g. battery) logs
pmset -g log # full power management log
https://support.apple.com/en-gb/HT202824 http://stuff.ttwedel.no/2017/08/secure-mac-osx-sleep.html
There are following modes:
- Apple menu () > Sleep - puts computer into Sleep mode (lower power consumption, CPU in low-power mode, etc.)
- After being in sleep mode for 3 hours it enters Standby mode where it writes session to SSD disk and powers down some components.
- If computer is idle for long time or battery runs low it will enter Safe Sleep (hibernation) mode where memory content is wrote to disk and computer is powered down.
Safe Sleep modes:
- 0 - default on desktops, system will not back up memory to storage
- 3 - default on laptops, system will store copy of memory on disk but memory will be powered so battery will eventually run out of power. If that happens system will restore from hibernate image
- 25 - system will store copy of memory on disk and will power down memory. Use this for true hibernation.
pmset -g|grep hibernatemode # current hibernatemode
sudo pmset -a hibernatemode 25 # set hibernatemode to 25
To reduce memory drain while sleeping you should disable TCPKeepAlive feature - this will prevent Mac from connecting to network and checking for updates (e.g. email, calendar):
sudo pmset -a tcpkeepalive 0 # disable
sudo pmset -a tcpkeepalive 1 # enable
Some Macbooks Pro come with two graphics cards: integrated low-performance and discrete high-performance. You can enable switching graphics cards in Energy Settings and OS X switches to high-performance card when:
- application that links against OpenGL is started
- external display is connected (always because only high-performance card handles external displays!)
To check which graphics card is currently in use open Activity Monitor, go to "Energy" tab and check bottom section. "Requires High Perf GPU" column on the same tab tells which app requires high-performance GPU.
pmset
allows GPU switching control:
sudo pmset -a gpuswitch <value>
allowed values:
- 0 - use low-performance card only (if external screen is already connected it will keep using high-performance card, if disconnected then external screen won't be detected when plugged in)
- 1 - use high-performance card only
- 2 - enable automatic switching
List of menu extras that can be added to menu bar: /System/Library/CoreServices/Menu Extras
.
To rearrange icons press Command (⌘) key, and drag it with mouse. To remove simply drag icon out of the menu bar.
/Library/Java/JavaVirtualMachines/
is a location expected by macOS's java_home
tool to look for Java installations:
/usr/libexec/java_home -V
macOS already comes with /usr/bin/java
command which is a wrapper tool that will use Java version pointed by JAVA_HOME
variable. If not set it will look for highest Java version under /Library/Java/JavaVirtualMachines/
.
# install various JDK versions, e.g.
brew install openjdk@11
brew install openjdk@8
# add symlinks for Java wrappers to find them
sudo ln -sfn /usr/local/opt/openjdk@8/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-8.jdk
sudo ln -sfn /usr/local/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk
# add aliases to ~/.zshrc or ~/.bash.rc or ~/.profile
alias set-java-11="export JAVA_HOME=`/usr/libexec/java_home -v11`"
alias set-java-8="export JAVA_HOME=`/usr/libexec/java_home -v1.8`"
# set JAVA_HOME to version you want to use
export JAVA_HOME=$(/usr/libexec/java_home -v1.8)
# verify that correct java version is used
java -version