How do I change desktop background with a terminal command?
None of these other solutions work on Mavericks anymore because Apple moved the settings to a sqlite DB. But that's ok because now it's easier, the png can be anywhere in the filesystem, and all desktops (even virtual) are updated.

 #!/usr/bin/env bash
 sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db "update data set value = '/path/to/any/picture.png'";
 killall Dock;


Or, add it as a function to your ~/.bash_profile and call it as a terminal command with any non-relative path.

#   Update all Wallpapers
function wallpaper() {
    sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db "update data set value = '$1'" &amp;&amp; killall Dock 
}


wallpaper ~/path/to/any/picture.png