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 com.apple.desktopservices DSDontWriteUSBStores -bool true

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

Show hidden files in Finder
defaults write com.apple.finder 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 com.apple.dock no-glass -bool true

Turn Dock autohide on
defaults write com.apple.dock autohide -bool true

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

Show Dock icons of hidden applications as translucent
defaults write com.apple.dock showhidden -bool true

Show iTunes track notifications in the Dock
defaults write com.apple.dock itunes-notifications -bool true

Disable menu bar transparency
defaults write NSGlobalDomain AppleEnableMenuBarTransparency -bool false

Show remaining battery life as percentage
defaults write com.apple.menuextra.battery ShowPercent -string “YES”

Show remaining battery life as time
defaults write com.apple.menuextra.battery ShowTime -string “YES”

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

Hide desktop icons upon quitting Finder
defaults write com.apple.finder QuitMenuItem -bool true

Disable get info and window animations in Finder
defaults write com.apple.finder 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 com.apple.finder FXDefaultSearchScope -string “SCcf”

Show Path bar in Finder
defaults write com.apple.finder ShowPathbar -bool true

Show Status bar in Finder
defaults write com.apple.finder 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 com.apple.LaunchServices LSQuarantine -bool false

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

Disable shadow in screenshots
defaults write com.apple.screencapture disable-shadow -bool true

Enable highlight hover effect on Dock for the grid view of a stack
defaults write com.apple.dock 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 com.apple.dock show-process-indicators -bool true

Don’t animate opening applications from the Dock
defaults write com.apple.dock 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 com.apple.NetworkBrowser BrowseAllInterfaces -bool true

Disable disk image verification
defaults write com.apple.frameworks.diskimages skip-verify -bool true
defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true
defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true

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

Display full POSIX path as Finder window title
defaults write com.apple.finder _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 com.apple.finder FXEnableExtensionChangeWarning -bool false

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

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

Disable Empty Trash Warning
defaults write com.apple.finder WarnOnEmptyTrash -bool false

Empty Trash securely by default
defaults write com.apple.finder EmptyTrashSecurely -bool true

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

Enable tap to click on Trackpad
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true

Map bottom right Trackpad corner to right-click
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadCornerSecondaryClick -int 2
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadRightClick -bool true

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

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

Remove useless icons from Safari bookmarks bar
defaults write com.apple.Safari 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 com.apple.terminal StringEncodings -array 4

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

Disable Ping in iTunes
defaults write com.apple.iTunes disablePing -bool true

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

Disable send and reply animations in Mail Application
defaults write com.apple.Mail DisableReplyAnimations -bool true
defaults write com.apple.Mail 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 com.apple.loginwindow TALLogoutSavesState -bool false
defaults write com.apple.loginwindow LoginwindowLaunchesRelaunchApps -bool false

Enable Dashboard Dev mode (Keeps widgets on the desktop)
defaults write com.apple.dashboard 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

Yahoo Account Password Change

Yahoo Account Password Change

So Yahoo!, are you saying that you let my account get hacked yet again? This despite my increasingly complex passwords that I now have to write down because I can’t remember them?

Yahoo Account Password Change

This is the fourth time this year I’ve seen this message. If this is part of some policy to force a password change every 90 days, then say so. Saying there was “unusual” account activity simply leads me to believe that you allowed someone to hack my account. Or worse yet, you’re somehow mistaking my own usage as “unusual.”

On the other hand it’s not like I really care too much anymore. As a user of your service since 1997 I have seen repeated changes for the worse, mostly removal of popular and useful services. Yahoo Groups? Useless and full of spammers. Yahoo Personals? Closed years ago. Yahoo Mail? Changed so many times it’s effectively useless.

Let’s take Yahoo Mail. When going into Yahoo Mail I now get a message stating that I need to upgrade my browsers. But they’re all upgraded to the latest already! You don’t need to tell me this every single time I login. Then there is the fact that clicking on messages in my inbox to open them may or may not work. Half the time nothing happens, a quarter of the time there is a time out error message, the rest of the time it works. If you delete an email it is a 50/50 chance that it takes you back to the inbox view or the next unread message. SPAM Emails get through on a constant basis, and then you’ve added an advertisers link to the top of my inbox that looks like an unread email. Yes it gets eyeballs and clicks – by accident. Yes I know you’re providing a free service, but this is beyond silly.

Then lets add in Yahoo’s penchant for Rollover ads, these are ads that go from itty bitty icons to huge “take over your screen” ads without any warning. Usually while you’re in the middle of reading something. Oh, and they’re also right on Yahoo News’ front page. A resource I used to use daily. Guess when the last time I looked at Yahoo! News was? I’ll give you a hint, it now numbers times per a year for about five minutes instead of daily for a couple of hours.

This problem is rampant across the entire Yahoo! platform. Look at what they did to Flickr. At first glance it LOOKS nice, even though they are blatantly copying other successful sites. But try using it for about 30 seconds and it becomes an exercise in frustration. The only good news is that the traffic has died down so much that the discussion groups are quiet.

Oh wait, that isn’t good news! I spent nearly five minutes trying to find my local photography group to find out when and where the next Meet-up and photoshoot was. The last post in a formerly busy group was the July 2013 Meetup notice. And nothing since then. A spot check of a variety of other formerly busy groups shows the exact same problem. So where is the improvement to service if people are having a hard time using it?

For an idea of other services that Yahoo has screwed up, er, I mean “closed due to a lack of popularity,” see the Yahoo! Wikipedia Article. Many of these were incredibly useful and popular services that Yahoo! closed in their infinite wisdom. Were they loosing money on any of these services? Doesn’t it make sense that even if it was only breaking even that they keep these services alive to bring people into the Yahoo.com “platform.” What’s really weird is how they purchased so many companies, and then ended up killing the companies within a couple of years.

Yahoo!, here is a wakeup call. I’m going to move totally away from your email service. I’m going to delete my flickr account and all my photos, and stop using your services. I know that this is only one set of eyeballs, and I probably don’t amount to much profit for you. But I’m also sure that I’m not the only one doing this.

How To Fix: H4ck3d by R3d Dr4GoN

How To Fix: H4ck3d by R3d Dr4GoN

This happened to me on both of my WordPress blogs, this one, and Pacific Northwest Photoblog. This could happen to any site though, not just WordPress sites.

How To Fix: H4ck3d by R3d Dr4GoN

First off, do not panic.

Either way clearing this up is pretty easy. In both cases there was a 301 Redirect in my .htaccess file on the very first line. I removed this and was able to get to sub pages. The main page continued to be a problem though. Looking closer I found that I had an index.php and index.html page. Since WordPress renders completely in PHP, the presence of Index.html was a bit strange. Taking a look at it I found:

HTML>

H4ck3d By R3d Dr4GoN






This Site Is

Very clearly this is incorrect. So I renamed Index.html to Index.hack, refreshed my main and everything was back to normal! After this be sure to change the password to your terminal/ftp user, create new SSH keys or create new ones if you don’t have any, and just to be safe, change your WordPress blog admin password.

While the actual hack was pretty amateurish, and was likely done by a script that exploited known security issues, it shows just how important proper security is in this day and age. And more importantly, it shows that no matter what you know, and how much you prepare – you will get hacked someday.

How To: Disable OS X Quick Look

How To: Disable OS X Quick Look

Quick Look in OS X is an awesome feature. I’m constantly using it to check out PDF files without needing to open them.

But in some environments, it doesn’t make sense or causes a huge amount of issues.

So to disable this, in the terminal type; (as root or admin user)

defaults write “$3/System/Library/LaunchAgents/com.apple.quicklook” Disabled -bool true

Restart the Finder, and you’re good to go!

This works in 10.6.x but apparently crashes 10.5.x (I’m not able to confirm the later as I don’t have 10.5)

How To: Force Safari to Download PDF Files

How To: Force Safari to Download PDF Files

I hate having my Internet Browser display PDF files when I click on them. I much prefer them to be downloaded. Here are two commands that changes this default behavior.

in terminal (as Admin or Root user) type:
defaults write com.apple.Safari
WebKitOmitPDFSupport -bool YES

Essentially you’re removing PDF Support from Safari so that it doesn’t know what to do with the files. Safari simply downloads the file to the /User/Downloads directory instead.

Keep in mind that updating Safari or Adobe Acrobat may change the PDF handling behavior back to the default. Yes, it is also possible to right click on a PDF and use “Download Linked File,” but this process is more automated.