HowTo: Turn off Linux Security Mechanisms
You are probably going to want to do this to make your initial exploit examples easier to work with and understand.
Turn off ASLR:
$ sudo echo 0 > /proc/sys/kernel/randomize_va_space
or
$ sudo sysctl -w kernel.randomize_va_space=0
Turn off NX (compile option to GCC)
-z execstack
Turn off stack smashing detection.
-fno-stack-protector
Turn off all other optimizations:
-O0