The first command will hide a file in the Mac OS X operating system. Replace the word filename with the actual name of the file or folder you would like to hide. The second command will unhide a file or folder. The third command will show all of the hidden files on your computer. The fourth command will hide all of the files that are supposed to be hidden on your computer. This command only works if you have unhidden files on your computer.
chflags hidden filename
chflags nohidden filename
defaults write com.apple.finder AppleShowAllFiles TRUE
defaults write com.apple.finder AppleShowAllFiles FALSE