Show:
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder

Hide:
defaults write com.apple.finder AppleShowAllFiles FALSE
killall Finder