Useful OS X Commands

Apple Icon - OSX

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

How to: Fix Kenwood Stereo MP3 file errors

I recently got a new (well, apparently from 2012,) Kenwood Stereo. The exact model number is the KDC-X498, but from my research most of the Kenwood stereos are pretty similar. It’s a pretty cool stereo as it has a USB port on it. I can plug in any phone with a USB cable and it’ll play music from it. It will also play MP3 files from a USB Drive.

Unfortunately there are a number of caveats to make this possible;
– The USB Drive is limited to 32GB in size
– The USB Drive must be formatted in Fat 32. Most are this way from the factory, so usually not a huge deal.
– Audio files must be in .mp3 format or .wav format. Some models will accept the .acc format also.
– Some stereos can only see a certain number of MP3s per a directory on the drive. Its roughly a thousand files, but on a 32GB drive that is easy to reach. If this happens, separate the files out into subdirectories. Or as I do, by Artist then Album.
– MP3s must be in 192k format. Not 320k VBR or some other format.

Despite all of this, my stereo (and several other models,) will suddenly display “NA File” while reading a USB drive full of MP3 files. After a lot of searching on the internet, most said to make sure that it’s in the right format. Well, I run a Mac, and spent several hours downgrading all my files to 192k yet still had the problem. After several more hours of searching and no answers at all, I finally figured out the problem.

The Kenwood Stereo’s firmware does not “skip” over the Macintosh’s .DS_Store files like every other operating system has been doing for years. Modern OSes see any file starting with a . (or period,) as a system file and ignores it, or processes it as appropriately. Not the Kenwood!

So to fix this, these can be disabled in the command line using these directions I wrote years ago.

Or, it’s easy to open up Terminal in OS X, and type ‘rm -rf ._*’ (without quotes.) This will delete all the .DS Store files and everything will magically work! Make sure you cd to the correct directory first , usually /Volumes/Crucial or something similar.

How to reinstall Apple App Store

How to reinstall Apple App Store

The Apple Store now allows Apple to bundle applications in an easy to download “iOS” like way. Since it’s release OS X application manufactures have been slowly moving over to it as a distribution channel for their apps. Some popular apps are now only available via the App store. If you are like me, one of the first things you might have done was to remove the App Store saying “I’m not going to play that game,” thinking we’d be able to continue to download apps as we wished.

Or perhaps you are in a corporate environment where the App Store has made managing Macs nearly a nightmare when it comes to application installation and asset management.

Unfortunately it seems that more and more application authors are going this way. It makes a bit of sense for the authors. It provides a better way to make some money off their hard work. It allows them to more easily digitally distribute their apps. And it saves them money on bandwidth.

The App Store itself is not a separately downloadable application though. The best, and quickest way, to reinstall it is to simply run and see if there is a Mac OS X Combo Updater install ready.

If not, you can download any Leopard or higher version from the Apple Support page. OS X Combo Updater 10.6.8 is a good start for most people; download it from here.

After that, you need to download an application installer program. Pacifist from Charlessoft is a good one.

Mount both Pacifist and and the Combo Updater Package. In Pacifist, go to the MacOSXUpdCombo10.6.8.pkg file and then use the search box in the right hand corner to search for store.



The first option that comes up is the Apple Store. Just click on the install button, make sure the check box “Install as Admin” is clicked, then hit OK. Enter your Administrator Password and Pacifist will start installing the application. When it’s done, go to your Applications and launch the App Store.

Please post in the comments if you have any questions.

How To: Manually update OS X time from Command Line

How To: Manually update OS X time from Command Line

Sometimes OS X’s time and date gets out of sync with the real world, and using the option “Set date and time automatically:” doesn’t always work.

You can use this command in terminal to update it manually:

ntpdate -u

The server address can be any of the Apple Servers such as or the free Time Servers,

This same command should work for most Unix/Linux Operating systems, as long as ntpdate is installed.

How To: Flush DNS Cache on OS X

Most users don’t need to use this command, but it’s very helpful for web developers and network admins to troubleshoot issues with web sites.

This command is run via terminal.

On Leopard (10.6) and Snow Leopard (10.7):

(as root or admin user) dscacheutil -flushcache

On all other version (10.0 – 10.4):

(as root or admin user) lookupd -flushcache