My Desktop fills up with screenshots quickly. One setting sends them somewhere else.
mkdir -p ~/Screenshots
defaults write com.apple.screencapture location ~/Screenshots
killall SystemUIServer
defaults write stores the folder in the screencapture preferences. The killall SystemUIServer line makes the system read the value again, and the change then applies to the next screenshot. Create the folder first, which is what the mkdir line does.
To go back, run defaults delete com.apple.screencapture location and restart SystemUIServer again. The same trick with defaults write com.apple.screencapture type jpg changes the file format. defaults read com.apple.screencapture shows all the values that are set.
Further reading: defaults manual page