I use OS X 10.8, I type the following
defaults write com.apple.Finder AppleShowAllFiles YES killall Finder
but still I cannot see any hidden files like .bash_history, .Trash, .cups, .gem etc. in user directory.
The bundle identifier is
com.apple.finder in lowercase.
defaults write com.apple.Finder AppleShowAllFiles YES would also write the setting as a string, but it doesn't usually matter though.
defaults write com.apple.finder AppleShowAllFiles -bool true osascript -e 'quit app "Finder"'
I had this problem. I tried Lauri's solution, and had intermittent success. I found that my particular problem was that I was sometimes running the command from root. Running it from standard permissions proved consistently successful, where running it from root proved consistently unsuccessful.
I have 2 Macs, both running 10.8.3. I was able to use the
defaults write com.apple.Finder AppleShowAllFiles YES
suggestion on my Mac Mini with success, but it did not work on the macbook pro no matter how many times (or which method I used) to restart Finder. When I used the "boolean" method, it worked for the macbook the first time. The macbook is a 2010 unit, and the mini from 2012, but all that should be only in the OS, and not related to hardware. very odd, but thanks very much for posting both options. I was beginning to drive myself crazy trying to see hidden files on the laptop. I even used "sudo" for the "AppleShowAllFiles" method, thinking it was a permissions thing, but that did not help.
defaults read com.apple.finder AppleShowAllFiles to read current status.
Note that it's different to use command with root user (e.g. sudo) or standard user and use com.apple.finder with Finder in lowercase.
For Hide hidden files
defaults write com.apple.finder AppleShowAllFiles 0 from current user terminal window not using
sudo su command.
For Show hidden files
defaults write com.apple.finder AppleShowAllFiles 1
Then relaunch Finder using
Tested on OS X 10.8.4.