Urm, all of the answers so far have been wrong with Rook's answer being correct.
Entering:
echo 0 | sudo tee /proc/sys/kernel/randomize_va_space
Followed by:
gcc -fno-stack-protector -z execstack -o bug bug.c
Disables ASLR, SSP/Propolice and Ubuntu's NoneXec (which was placed in 9.10, and fairly simple to work around see the mprotect(2) technique to map pages as executable and jmp) should help a little, however these "security features" are by no means infallible. Without the `-z execstack' flag, pages have non-executable stack markings.