Useful OS X Commands

Useful OS X Commands

Here is a list of a bunch of potentially useful OS X Commands. These are going to be mostly for power users, system admins, OS X hackers, and programmers. Normal users will likely never need these, thus they are presented without use directions.

Commands were gathered via the .OSX group on GitHub. Please feel free to comment below and add any other useful commands you find!

Most commands are set to enable the action with the -true flag. Disable action by replacing it with -false.

Stop the creation of .DS_Store and AppleDouble files on USB Drives
defaults write DSDontWriteUSBStores -bool true

Stop the creation of .DS_Store files on Network Drives
defaults write DSDontWriteNetworkStores true

Show hidden files in Finder
defaults write AppleShowAllFiles YES

Prevent MDS from attempting to Index
sudo touch /Volumes/your volume name here/.metadata_never_index

Disable Indexing and Searching of Volumes
sudo mdutil -i off -d /Volumes/VolumeName

Delete existing Spotlight Index
sudo rm -rfv /.Spotlight-V100

Enable full keyboard access for all controls
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3

Enable subpixel font rendering on non-Apple LCD Screens and non-Retina Monitors
defaults write NSGlobalDomain AppleFontSmoothing -int 2

Show the ~/Library folder in GUI (Can be used to show other “hidden” folders that some Applications add)
chflags nohidden ~/Library

Add “Anywhere” option to the “Allow apps downloaded from:” under the General Tab of Security and Privacy
sudo spctl –master-disable

Enable the 2D Dock
defaults write no-glass -bool true

Turn Dock autohide on
defaults write autohide -bool true

Remove Dock display delay
defaults write autohide-delay -float 0 && killall Dock

Show Dock icons of hidden applications as translucent
defaults write showhidden -bool true

Show iTunes track notifications in the Dock
defaults write itunes-notifications -bool true

Disable menu bar transparency
defaults write NSGlobalDomain AppleEnableMenuBarTransparency -bool false

Show remaining battery life as percentage
defaults write ShowPercent -string “YES”

Show remaining battery life as time
defaults write ShowTime -string “YES”

Always show scrollbars
defaults write NSGlobalDomain AppleShowScrollBars -string “Auto”

Hide desktop icons upon quitting Finder
defaults write QuitMenuItem -bool true

Disable get info and window animations in Finder
defaults write DisableAllAnimations -bool true

Show all filename extensions in Finder
defaults write NSGlobalDomain AppleShowAllExtensions -bool true

Use current directory as default search scope in Finder
defaults write FXDefaultSearchScope -string “SCcf”

Show Path bar in Finder
defaults write ShowPathbar -bool true

Show Status bar in Finder
defaults write ShowStatusBar -bool true

Expand save panel by default
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true

Expand print panel by default
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true

Disable dialog box: “Are you sure you want to open this application?” (Note, this disables OS X Security and anti-malware features)
defaults write LSQuarantine -bool false

Disable dialog box: “Are you sure you want to open this application?” (for one application)
xattr -d ~/Downloads/ApplicationName (before installing)
xattr -dr /Applications/ApplicationName (after installing)

Disable shadow in screenshots
defaults write disable-shadow -bool true

Enable highlight hover effect on Dock for the grid view of a stack
defaults write mouse-over-hilte-stack -bool true

Enable spring loading for all Dock items
defaults write enable-spring-load-actions-on-all-items -bool true

Show indicator lights for open applications in the Dock
defaults write show-process-indicators -bool true

Don’t animate opening applications from the Dock
defaults write launchanim -bool false

Display ASCII control characters using caret notation in standard text views
(Try e.g. `cd /tmp; unidecode “\x{0000}” > cc.txt; open -e cc.txt`)
defaults write NSGlobalDomain NSTextShowsControlCharacters -bool true

Disable press-and-hold for keys in favor of key repeat (enable key repeat)
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false

Set keyboard repeat rate
defaults write NSGlobalDomain KeyRepeat -int 0.05 (Fast)
defaults write NSGlobalDomain InitialKeyRepeat -int 15 (Slow)

Disable auto-correct (Does not impact MS Office)
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false

Disable opening and closing window animations
defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool false

Enable AirDrop over Ethernet (also works for Lion)
defaults write BrowseAllInterfaces -bool true

Disable disk image verification
defaults write skip-verify -bool true
defaults write skip-verify-locked -bool true
defaults write skip-verify-remote -bool true

Automatically open a new Finder window when a volume is mounted
defaults write auto-open-ro-root -bool true (Read-only)
defaults write auto-open-rw-root -bool true (Read-write)
defaults write OpenWindowForNewRemovableDisk -bool true

Display full POSIX path as Finder window title
defaults write _FXShowPosixPathInTitle -bool true

Increase window resize speed for Cocoa applications
defaults write NSGlobalDomain NSWindowResizeTime -float 0.001

Disable the warning upon changing file extension
defaults write FXEnableExtensionChangeWarning -bool false

Show item info below desktop icons
/usr/libexec/PlistBuddy -c “Set :DesktopViewSettings:IconViewSettings:showItemInfo true” ~/Library/Preferences/

Enable snap-to-grid for desktop icons (Same as OS 9 GUI command)
/usr/libexec/PlistBuddy -c “Set :DesktopViewSettings:IconViewSettings:arrangeBy grid” ~/Library/Preferences/

Disable Empty Trash Warning
defaults write WarnOnEmptyTrash -bool false

Empty Trash securely by default
defaults write EmptyTrashSecurely -bool true

Require password immediately after sleep or screen saver begins (reduces the normal delay)
defaults write askForPassword -int 1
defaults write askForPasswordDelay -int 0

Enable tap to click on Trackpad
defaults write Clicking -bool true

Map bottom right Trackpad corner to right-click
defaults write TrackpadCornerSecondaryClick -int 2
defaults write TrackpadRightClick -bool true

Disable Safari thumbnail cache for History and Top Sites
defaults write DebugSnapshotsUpdatePolicy -int 2

Enable Safari debug menu (most useful for Web Developers)
defaults write IncludeInternalDebugMenu -bool true

Remove useless icons from Safari bookmarks bar
defaults write ProxiesInBookmarksBar “()”

Add a context menu item to web view for showing the Web Inspector
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true

Only use UTF-8 in Terminal Application
defaults write StringEncodings -array 4

Disable the Ping sidebar in iTunes
defaults write disablePingSidebar -bool true

Disable Ping in iTunes
defaults write disablePing -bool true

Make ⌘ + F focus the search input in iTunes
defaults write NSUserKeyEquivalents -dict-add “Target Search Field” “@F”

Disable send and reply animations in Mail Application
defaults write DisableReplyAnimations -bool true
defaults write DisableSendAnimations -bool true

Disable Resume system-wide
defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool false

Disable the “reopen windows when logging back in” dialog box (Leaves default to reopen windows)
defaults write TALLogoutSavesState -bool false
defaults write LoginwindowLaunchesRelaunchApps -bool false

Enable Dashboard Dev mode (Keeps widgets on the desktop)
defaults write devmode -bool true

Reset Launchpad
[ -e ~/Library/Application\ Support/Dock/*.db ] && rm ~/Library/Application\ Support/Dock/*.db

Disable local Time Machine backups
hash tmutil &> /dev/null && sudo tmutil disablelocal

Leave a Reply