Go to file
2015-09-24 01:11:08 +02:00
assets Add repository logo 2015-09-24 01:11:08 +02:00
contributing.md Add contribution guidelines 2015-09-22 23:37:20 +02:00
README.md Add repository logo 2015-09-24 01:11:08 +02:00

A curated list of shell commands and tools specific to OS X.

“You dont have to know everything. You simply need to know where to find it when necessary.” (John Brunner)

Awesome

If you want to contribute, please read the contribution guidelines.

Table of Contents

Developer

Install command line tools without Xcode

xcode-select --install

Disks

Disable sudden motion sensor (useless for SSDs)

sudo pmset -a sms 0

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

Input Devices

Disable/enable auto-correct

defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool true

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

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.