Desc | Shortcut |
---|---|
bring up 'force quit applications' menu | cmd + option + escape |
take screenshot of all screens | cmd + shift + 3 |
take a partial screenshot | cmd + shift + 4 |
lock screen | cmd + shift + eject |
open -a APPLICATION
# list kernel extensions
kextstat -l
# unload kernel extensions
kextunload -b <id>
softwareupdate -h
apple key + ? , search for the help menu
ulimit -n 4096
# get launch list
launchctl list
# remove item
launchctl remove <svc>
Create hosts-style file in /etc/resolver/<domain>
See man 5 resolver
hdiutil chpass /path/to/disk
hdiutil burn <image>
diskutil list
# List shared libraries
otool -L <executable>
# Replace XXXXX with MB * 2048 (eg a 4 gig is 8388608 (4096 * 2048))
diskutil erasevolume HFS+ 'RAM Disk' `hdiutil attach -nomount <ram://XXXXX>`
action | keypress |
---|---|
Recovery Mode | Cmd + r |
Upgrade to latest compatible macOS | Option + Cmd + r |
Verbose Mode | Cmd + v |
Single-user Mode | Cmd + s |
Safe Mode | Shift |
Apple Diagnostics / Hardware Test | D |
Boot removable device | C |
Boot from network | N |
Startup Manager | Option |
Reset NVRAM | Cmd + Option + P + R |
All the neat tools for diagnosing busy channels, noise, etc. are in the 'Window' tab
/System/Library/CoreServices/Applications/Wireless\ Diagnostics.app/Contents/MacOS/Wireless\ Diagnostics
# List APs
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s
vmstat
man pmset
Use caffeinate
to prevent the system from sleeping
A bunch of dtrace under the hood
/usr/bin/power_report.sh
/Library/Preferences and ~/Library/Preferences
man defaults
# dump database
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -dump
#Remove Open With entries
lsregister -kill -r -domain local -domain system -domain user
PreferencePanes framework
/System/Library/PreferencePanes
scutil - system config utility
- help command in the shell has lots of goodies
- use
n.add KEY
+n.watch
to get notified of config changes
leaks(1)
csrutil(1)
copy to ~/Library/Fonts
sample PID -file OUTPUT
tmutil listlocalsnapshotdates
tmutil deletelocalsnapshots DATE
Note: Voids your warranty, haven't tried it myself
# Disable GateKeeper
sudo spctl --master-disable
# Disable Library Validation
sudo defaults write /Library/Preferences/com.apple.security.libraryvalidation.plist DisableLibraryValidation -bool true
# (From Recovery Mode) Disable System Integrity Protection
csrutil disable
# (From Recovery Mode) Disable Apple Mobile File Integrity
nvram boot-args="amfi_get_out_of_my_way=1"
character | description |
---|---|
á | Option + e, a |
Á | Option + e, Shift + a |
é | Option + e, e |
É | Option + e, Shift + e |
í | Option + e, i |
Í | Option + e, Shift + i |
ñ | Option + n, n |
Ñ | Option + n, Shift + n |
ó | Option + e, o |
Ó | Option + e, Shift + o |
ú | Option + e, u |
Ú | Option + e, Shift + u |
ü | Option + u, u |
Ü | Option + u, Shift + u |
¿ | Shift + Option + ? |
¡ | Option + 1 |
« | Option + \ |
» | Shift + Option + \ |
quotation dash (---) | Shift + Option + - |
opendiff foo bar
~/Library/Keyboard Layouts
- https://web.archive.org/web/20140812170917/https://developer.apple.com/library/mac/documentation/TextFonts/Reference/TextInputSourcesReference/Reference/reference.html
- https://web.archive.org/web/20160318180309/https://developer.apple.com/library/mac/technotes/tn2056/_index.html
- Wiping Intel-based macs
- https://opensource.apple.com/
- https://github.com/herrbischoff/awesome-osx-command-line
- https://www.raywenderlich.com/151741/macos-development-beginners-part-1
Notes: 32-bit support is dropped
defaults write -g CGFontRenderingFontSmoothingDisabled -bool NO
# then reboot
Quicklook
Creates thumbnails in the Finder
Can see the plugins in /System/Library/QuickLook and ~/Library/QuickLook
Not a standalone executable, implements QuickLookGeneratorPluginFactory
Uses the quicklookd daemon
qlmanage
is used to maintain the plugins and the daemon
# Link files into macho64 for use on macOS
ld -macosx_version_min 10.7.0 -lSystem file.o
backwards compatible with syslog
logs are binary, not textual
log
- access system log messages
aslmanager
# Get system resource limits
launchctl limit
Called by launchd to execute shell scripts (very cron)
/etc/periodic/
- scripts
/etc/periodic.conf - override the default periodic config
http://ss64.com/osx/launchctl.html https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/launchctl.1.html http://launchd.info/
Spotlight
desc | command |
---|---|
manages the metadata for spotlight | mdutil |
query the spotlight indexes | mdfind |
test/list spotlight plugins | mdimport |
list the metadata of a file | mdls |
diagnose Spotlight issues | mddiagnose |
touch the file .metadata_never_index
sandbox-exec - deprecated
examples - /usr/share/sandbox
and /System/Library/Sandbox/Profiles/
TinySCHEME (reminds me of VXE)
asctl - App sandbox control tool
- notifyd
- notifyutil
- AddressBook
- AppKit
- AudioToolBox
- ApplicationServices
- Automator
- CalendarStore
- Cocoa
- CoreAudio
- CoreFoundation
- CoreLocation
- CoreMotion
- DirectoryService
- EventKit
- Foundation
- GSS
- iAd
- ImageIO
- InstantMessage
- IOKit
- Kernal
- LDAP -> OpenDirectory
- Message
- PreferencePanes
- QuickLook
- SceneKit
- ScreenSaver
- Scripting (deprecated?)
- Security
- ServerNotification
- PubSub (RSS/Atom support!)
- StoreKit
- SyncServices
darwinup - manage archives for the system
ls -lO
Replaces HFS+
OS X 10.12+
- Container is base storage unit, generally 1:1 mapping to GPT
- 64-bit inaode numbers
- Nanosecond timestamp granularity
- Extensible block allocation
- Sparse files
- COW metadata
- Extended attributes
- TRIM operations
- Native encryption support, with multi-key encryption support
- SMB compatible
(like inotify for mac) /dev/fsevents
Better to use Spotlight, apparently shrug
The old filesystem for macOS
- Could be case sensitive/insensitive
- Could be journaled/unjournaled
Uncomment the /usr/libexec/getty console line in /etc/ttys
arch
lipo
script -r
# do whatever, then exit
script -p typescript
Bundles
Can be accessed by NSBundle
Contents/
CodeResources/
Info.plist Main package manifest
MacOS/ Binary contents
PkgInfo Eight character identifier of package
Resources/ GUI + project files
Version.plist
_CodeSignature/
CodeResources
/System/Library/Frameworks (and also /System/Library/PrivateFrameworks)
Contents/
Headers/ - .h files
Modules/
Resources/
Versions/
A/
Current/ - symlink to current version
path | description |
---|---|
/etc/resolv.conf | not used |
/private/etc/hosts | force resolution |
/Library/Preferences/SystemConfiguration/preferences.plist | preferences |
/etc/resolver/ |
domain nameserver overrides |
# On Yosemite+
sudo discoveryutil mdnsflushcache
# 10.10.4+
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
# Use Mac resolution service
dns-sd -G v4 example.com
# Query via DirectoryService
dscacheutil -q host -a name example.org
# Don't use Mac resolution
nslookup example.com
scutil --dns
listens port 5353
resolver(5)
audit logs stored in /var/audit
audit
- utility to control the auditing system
Use praudit
to output log in human readable form
Use praudit /dev/auditpipe
to access the logs in real time
Use auditreduce
to filter records from the file
/Library/Scripts
Applescript Editor
Uses AppleEvents
Use osascript and Automator
export AEDebugSends=1 AEDebugReceives=1
# directory service command line utility
dscl
dscl . -read /Users/`whoami`
# examine/change state of opendirectoryd
odutil
man plist
# manipulate/check plist files
plutil
Folder is /private/tftpboot
, but can be changed by adjusting /System/Library/LaunchDaemons/tftp.plist
sudo launchctl load -F /System/Library/LaunchDaemons/tftp.plist
sudo launchctl start com.apple.tftpd
# Connect to a single VPN
osascript -e 'Tell app "Tunnelblick" to connect "example-vpn"'
# Disconnect all VPNs
osascript -e 'Tell app "Tunnelblick" to disconnect all'
/Library/Widgets
Made of HTML+JS :-P
Dashboard disabled in 10.10 (Yosemite), Moved to Notification Center
Edit MinimumSDKVersion in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Info.plist
From: https://stackoverflow.com/questions/11424920/how-to-point-xcode-to-an-old-sdk-so-it-can-be-used-as-a-base-sdk/11424966#11424966 https://stackoverflow.com/questions/18423896/is-it-possible-to-install-ios-6-sdk-on-xcode-5 https://gist.github.com/rnapier/3370649
security(1) - dump keychains
codesign(1) - create/manipulate code signatures
csreq(1)
code signing is optional in macOS
unsigned code is killed by the kernel in iOS
say "talking from the command line"
Speech Synthesis Programming Guide
speech synthesizers located in /System/Library/Speech/Synthesizers
voices located in /System/Library/Speech/Voices
NSSpeechSynthesizer class in AppKit
NSSpeechSynthesizer *synvox = [NSSpeechSynthesizer new];
NSString *hw = @"Hello world";
[synvox startSpeakingString:hw];
The Carbon API provides more programmatic control if you need it
Note: this is for the CLI to the keychains and Security framework, not a general page.
# Print password
security find-generic-password -a "${account}" -s "${name}" -w