5.8 KiB
5.8 KiB
Awesome OS X Command Line
A curated list of shell commands and tools specific to OS X.
“You don’t have to know everything. You simply need to know where to find it when necessary.” (John Brunner)
If you want to contribute, please read the contribution guidelines.
Table of Contents
- Developer
- Disks
- Finder
- Fonts
- Hardware
- Media
- Networking
- Printing
- Package Managers
- Security
- System
- Miscellaneous
Developer
Install command line tools without Xcode
xcode-select --install
Disks
Repair file permissions
sudo diskutil repairPermissions /
Finder
Hide folder in finder
SetFile -a V <FOLDER>
Fonts
Clear font cache for all users
sudo atsutil databases -removeUser
atsutil server -shutdown
atsutil server -ping
Clear font cache for current user
atsutil databases -removeUser
atsutil server -shutdown
atsutil server -ping
Hardware
List all hardware ports
networksetup -listallhardwareports
Show all power management settings
sudo pmset -g
Media
Convert audio file to iPhone ringtone
afconvert input.mp3 ringtone.m4r -f m4af
Networking
Clear DNS cache
sudo dscachutil -flushcache && sudo killall -HUP mDNSResponder
Enable/disable Bonjour
defaults write /System/Library/LaunchDaemons/com.apple.mDNSResponder ProgramArguments -array-add "-NoMulticastAdvertisements"
defaults write /System/Library/LaunchDaemons/com.apple.mDNSResponder ProgramArguments -array "/usr/sbin/mDNSResponder" "-launchd"
Remove Apple Remote Desktop settings
sudo rm -rf /var/db/RemoteManagement
sudo rm /Library/Preferences/com.apple.RemoteDesktop.plist
rm ~/Library/Preferences/com.apple.RemoteDesktop.plist
sudo rm -r /Library/Application\ Support/Apple/Remote\ Desktop/
rm -r ~/Library/Application\ Support/Remote\ Desktop/
rm -r ~/Library/Containers/com.apple.RemoteDesktop
Renew DHCP lease
sudo ipconfig set en0 DHCP
Show DHCP info
ipconfig getpacket en0
Show Wi-Fi connection history
defaults read /Library/Preferences/SystemConfiguration/com.apple.airport.preferences | grep LastConnected -A 7
Show Wi-Fi network passwords
security find-generic-password -ga "ROUTERNAME" | grep "password:"
Package Managers
- Fink - The full world of Unix Open Source software for Darwin.
- Homebrew - The missing package manager for OS X.
- MacPorts - Compile, install and upgrade either command-line, X11 or Aqua based open-source software.
Printing
Clear print queue
cancel -a -
Security
Add/remove Gatekeeper exceptions
spctl --add /path/to/Application.app
spctl --remove /path/to/Application.app
Check FileVault status
sudo fdesetup status
Securely remove file/directory/force
srm /path/to/file
srm -r /path/to/directory/
srm -rf /path/to/complete/destruction
System
Advanced system and performance report
sudo sysdiagnose -f ~/Desktop/
Check/set/turn off system sleep idle time
sudo systemsetup -getcomputersleep
sudo systemsetup -setcomputersleep 60
sudo systemsetup -setcomputersleep Never
Copy to/from clipboard
cat whatever.txt | pbcopy
pbpaste > whatever.txt
Disable/enable Notification Center
launchctl unload -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist && killall -9 NotificationCenter
launchctl load -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist
Disable/enable transparency in menu and windows
defaults write com.apple.universalaccess reduceTransparency -bool true
defaults write com.apple.universalaccess reduceTransparency -bool false
Eject all mountable volumes
osascript -e 'tell application "Finder" to eject (every disk whose ejectable is true)'
Enable/disable root user
dsenableroot
dsenableroot -d
Enable/disable/check safe mode
sudo nvram boot-args="-x"
sudo nvram boot-args=""
nvram boot-args
List all apps downloaded from App Store
find /Applications -path '*Contents/_MASReceipt/receipt' -maxdepth 4 -print |\sed 's#.app/Contents/_MASReceipt/receipt#.app#g; s#/Applications/##'
Load/unload kernel extensions
sudo kextload -b com.apple.driver.ExampleBundle
sudo kextunload -b com.apple.driver.ExampleBundle
Purge memory cache
sudo purge
Show/disable/enable autocorrect setting
defaults read -g NSAutomaticSpellingCorrectionEnabled
defaults write -g NSAutomaticSpellingCorrectionEnabled -bool false
defaults write -g NSAutomaticSpellingCorrectionEnabled -bool true
Show build number of OS
sw_vers
Show current screen resolution
system_profiler SPDisplaysDataType | grep Resolution
Miscellaneous
Set wallpaper
osascript -e 'tell application "Finder" to set desktop picture to POSIX file "/path/to/picture.jpg"'
License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.