Unhide invisible files from the command line
For files hidden by prepended .
To show:
defaults write com.apple.finder AppleShowAllFiles YES; killall Finder

To hide:
defaults write com.apple.finder AppleShowAllFiles NO; killall Finder

edit: as per RikerW's advice, to shorten these long strings into some shorter strings, add the following line to ~/.bash_profile from your favorite text editor:
alias showall='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder'
alias hideall='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder'

do note that you will have to do source ~/.bash_profile to update your shell with the new aliases.

For files hidden from the GUI:
To show:
sudo chflags nohidden /path/to/file

To hide:
sudo chflags hidden /path/to/file

Do bear in mind that this completely removes the hidden flag.