Mac OSX Command Line Notes

To flush DNS cache:

sudo dscacheutil -flushcache

To mount a DMG:

hdiutil attach ‘/path/to/dmg’

To install a .pkg or .mpkg

sudo installer -pkg ‘/path/to/pkg’ -target /

To unset the “locked” flag on files (usually copied as read-only from another system):

chflags nouchg [file name]

To use find and xargs to do interesting things to LARGE lists of files (“xxx” can be any unique sequence of characters.  Most online examples use … -I “{}” …):

find . -name *.txt | xargs –Ixxx rm xxx

To get a quick count of files in a directory/diretories without counting meta files (files/folders that start with “.”):

ls | wc -l

To en|disable Spotlight in Mac OSX:

sudo mdutil -a -i off|on

To remove the menu bar icon:

sudo chmod 600 /System/Library/CoreServices/Search.bundle/Contents/MacOS/Search

killall SystemUIServer


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: