Active9 years, 5 months ago
I want to turn off ASLR on my own PC. But each time I type 'sudo echo 0 > /proc/sys/kernel/randomize_va_space', the system shows that 'Permission denied'. How can I make it work? By the way, my OS kernel is 2.6.30.
Hope anyone can give me a hand.
Regards.
Disabling aslr pax is a patch for the linux kernel that implements least privilege protections for memory pages the leastprivilege approach allows computer programs to do only what they have to do in order to be able to execute properly and nothing more, in computer security executablespace protection marks memory regions as nonexecutable such. How can I temporarily disable ASLR (Address space layout randomization)? According to an article How Effective is ASLR on Linux Systems?
Summer_More_More_TeaSummer_More_More_Tea52366 gold badges1010 silver badges2727 bronze badges
migrated from stackoverflow.comApr 4 '10 at 4:44
This question came from our site for professional and enthusiast programmers.
3 Answers
This is a common problem with sudo and shell redirection. The 'sudoness' doesn't propagate past the redirection. One way to get around it is
jannebjanneb
In your command, the I/O redirection
>
is handled by the current shell. The command is seen by the interpreter as 3 parts:sudo echo 0
>
/proc/sys/kernel/randomize_va_space
The
echo
is executed using the superuser privilege while the current shell (with normal user privilege) tries to write to /proc/sys/kernel/randomize_va_space
, and thus triggers a Permission denied
error.There are several ways to overcome this. The first way is to run a shell with superuser privilege and pass the command to the shell using the
-c
switch:(You may use
sh
for POSIX shell and bash
for Bash)Another way is to use the
tee
command. The tee
command copies the contents from standard input to the standard output (usually means the 'screen') as well as the listed files. Therefore, the following command prints the character A
to the standard output as well as the files output1.txt
and output2.txt
.In your problem, writing to
/proc/sys/kernel/randomize_va_space
needs the superuser privilege while echo
-ing 0
does not. So, the solution is:The final redirection to
/dev/null
prevents the 0
from printing to the screen.Siu Ching Pong -Asuka Kenji-Siu Ching Pong -Asuka Kenji-
The
sudo
only works for your echo command (not after the pipe).You can try:
ChristopheD![Aslr Aslr](/uploads/1/2/5/8/125834895/116993916.png)
![Aslr Aslr](/uploads/1/2/5/8/125834895/409527713.png)
5,39422 gold badges1111 silver badges1010 bronze badges