© 2020-2023 by Zack Smith. All rights reserved.
A lot of what I recommend in my Linux command-line tips page also applies to MacOS.
This page provide some addition MacOS-specific command-line tricks.
Devices
List devices
MacOS doesn't have the usual lsusb and lspci commands, so we have to add equivalents.
- alias lsusb="system_profiler SPUSBDataType"
- alias lspci="ioreg -P IPCI -l -w 0"
Print the CPU type
- sysctl machdep.cpu.brand_string
Print the number of CPU cores
- sysctl machdep.cpu.cores_per_package
Print the memory page size
- sysctl hw.pagesize
Print the model info
- sysctl hw.model
Power
Live display of CPU cores' speeds and power usages
- sudo powermetrics
Audio
Play an audio file
- afplay file.mp3
Images
Convert an image to a different size
function resize_image { |
Network
Wifi sniff mode
- sudo airport en0 sniff 1
Do an sftp with PEM file
- sftp -i myfile.pem user@host
Change Wifi MAC address
There's a chance this may only work on Intel Macs.
function MAC { |
WiFi rate limit
This works in MacOS 10.9 and earlier:
- sudo ipfw pipe 1 config bw 1KByte/s
Privacy
Disable iCloud
iCloud is now harder to disable than in the past.
- Go into Settings, click on your account, and specifically disable it. Some parts of it will still be enabled.
- You will then only need to log in with your Apple ID to install software.
The Privacy, Security and OSINT podcast has a magazine and its 5th issue covers Ventura privacy:
Deselect file types that Spotlight scans
- Go into Settings and on the left side, select Spotlight/Siri.
- Uncheck the file types that you don't want scanned e.g. all of them.
Disable Spotlight indexing
- Method 1
sudo mdutil –a -i off |
- Method 2
sudo launchctl unload -w \ |
Software
Install Rosetta
softwareupdate --install-rosetta --agree-to-license |
Install command-line utilities
Just type git
or gcc
in Terminal
and hit Enter
and you'll be prompted.
iOS Simulator
These will require that you have Xcode installed.
Launch the Simulator app
open /Applications/Xcode.app/Contents/\ |
List iOS devices
- xcrun simctl list devices -j
List simulators
- xcrun simctl list
Erase all simulators
- xcrun simctl erase all
Insert a photo into the running simulator
- xcrun simctl addmedia booted myfile.png
Take a screenshot
- xcrun simctl io booted screenshot image.png
Record the simulator's screen
- xcrun simctl io booted recordVideo movie.mov
Cause the simulator to open a URL
- xcrun simctl openurl booted 'myappscheme:dothis'
Install your app
- xcrun simctl install booted MyApp.app
The full path to your .app should be used, which will be in DerivedData.
Uninstall your app
- xcrun simctl uninstall booted MyApp
Launch your app
- xcrun simctl launch booted MyApp
Kill your app
- xcrun simctl terminate booted appname
- xcrun simctl launch booted appname
Stream your app's logs
- xcrun simctl spawn booted log stream - level=debug
Dump the defaults for your app
- xcrun simctl spawn booted defaults read com.company.app
Set a default value for your app
xcrun simctl spawn booted defaults \ |
Delete unavailable simulators
- xcrun simctl delete unavailable
Related links