In any shell, you can loop over the files whose name contains a space. Replacing the spaces with underscores is easy in bash, ksh and zsh with the ${VARIABLE//PATTERN/REPLACEMENT} construct.
for x in *" "*; do
mv -- "$x" "${x// /_}"
done
On Debian, Ubuntu and derivatives, you can use the Perl rename (other distributions ship a different program as rename, and that program isn't helpful here).
rename 's/ /_/g' ./*
An obligatory zsh solution:
autoload zmv
zmv '(*)' '${1// /_}'
Or:
autoload zmv
zmv '*' '${f// /_}'
An obligatory POSIX solution:
for x in *" "*; do
y=$(printf %s/ "$x" | tr " " "_")
mv -- "$x" "${y%/}"
done