Set Finder Preferences – Command Line

SettingĀ  the following Finder Preferences enables the specified drives to be shown on the Desktop, the same as going to Finder, Preferences, General and ticking the boxes

defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true
defaults write com.apple.finder ShowHardDrivesOnDesktop -bool true
defaults write com.apple.finder ShowMountedServersOnDesktop -bool true
defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true

To set it so that a New Finder Window shows your home folder, enter the following into Terminal

defaults write com.apple.finder NewWindowTarget PfHm

Show Hidden Files

You can see hidden files by in the Terminal, but if you wish to display them in Finder then you will need to do the following

Open Terminal and type

defaults write com.apple.Finder AppleShowAllFiles TRUE

then

killall Finder

Open a Finder window and you will see the previously hidden files, if you wish to switch back then you can do the following

Open Terminal and type

defaults write com.apple.Finder AppleShowAllFiles FALSE

then

killall Finder

Open a Finder window and all the unhidden files will now revert to being hidden again.