In Terminal, type these commands:
To show:
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
To hide:
defaults write com.apple.finder AppleShowAllFiles FALSE
killall Finder
Solution originally posted by Brooks on March 23, 2007 at http://www.brooksandrus.com/blog/2007/03/23/mac-os-x-show-hide-hidden-files-in-finder/

One Comment
If you want to hide a certain file or folder in the way of the classic Mac OS, you may use the SetFile command of Mac OS X:
To hide a file or folder, type:
SetFile -a V filename
To show a file or folder, type:
SetFile -a v filename