Go to file
2015-09-22 23:23:45 +02:00
README.md Initial command loadout 2015-09-22 23:23:45 +02:00

Awesome OS X Command Line

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

Table of Contents

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

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

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"'