Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am using Ubuntu 12.04 32-bits now for some experiment I need to disable ASLR how can I do this? and after that what should I do to enable ASLR again?

share|improve this question

3 Answers 3

up vote 9 down vote accepted

According to an article How Effective is ASLR on Linux Systems?, you can configure ASLR in Linux using the /proc/sys/kernel/randomize_va_space interface.

The following values are supported:

  • 0 – No randomization. Everything is static.
  • 1 – Conservative randomization. Shared libraries, stack, mmap(), VDSO and heap are randomized.
  • 2 – Full randomization. In addition to elements listed in the previous point, memory managed through brk() is also randomized.

So, to disable it, run

echo 0 | sudo tee /proc/sys/kernel/randomize_va_space

and to enable it again, run

echo 2 | sudo tee /proc/sys/kernel/randomize_va_space

This won't survive a reboot, so you'll have to configure this in sysctl. Add a file /etc/sysctl.d/01-disable-aslr.conf containing:

kernel.randomize_va_space = 0

should permanently disable this.

share|improve this answer

I would do this in a VM if I were you for obvious reasons. Also, to do this I'm pretty sure you're going to compile your own kernel with the ASLR disabled. I do not believe there is any way to do this that doesn't involve re-compiling your kernel.

gcc -fno-stack-protector -z execstack -o OUTPUT INPUT.c
share|improve this answer

This feature is called personality

setarch `uname -m` -R /bin/bash

This will open a new bash shell for you.
Run any program in this shell will have ASLR disabled.
exit the shell if you have done your work.

And of course you can setarch `uname -m` -R <PATH_TO_YOUR_PROGRAM> directly


On i386, ulimit -s unlimited can "disable" ASLR. This is a well-known trick for fun and profit.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.