Take the 2-minute tour ×

Is there a way to run an executable binary file under Linux which does not have the execute bit set? chmod +x is not an option.

E.g. it's permissions may be r--r--r-- only.

Executing scripts is possible without setting the execute bit and putting in a hash-bang by passing the source to the interpreter, e.g. bash script.sh or python script.py.

So is there something like execute abinaryfile that will load the object code into memory and run it?

share|improve this question
make a copy and chmod an option? –  TiCL Sep 29 '11 at 23:45
No, I'm wondering if there is a way to execute a binary in an environment where the permission bit can't be set (on the given file or any copies of it...) –  Tom Sep 30 '11 at 1:34
add comment

2 Answers

up vote 13 down vote accepted

You can use /lib/ld*.so as an ELF interpreter, like so:

$ cp /bin/ls /tmp/ls
$ chmod a-x /tmp/ls
$ /lib/ld-linux.so.2 /tmp/ls

The actual name differs from architecture to architecture. Some names include /lib/ld-linux.so.2, /lib/ld-linux-x86-64.so.2 and /lib/ld-2.7.so. You can probably find it singularly as /lib/ld*.

share|improve this answer
great info.....anyways what does ld stands for? –  Vineet Menon Nov 14 '11 at 11:43
@VineetMenon ld is the program linker/loader. It finds and loads the shared libraries used by the program, and then executes it. ld-linux handles ELF binaries. –  Daniel Beck Nov 14 '11 at 11:57
Ok, what if /lib/ld-linux.so.2 isn't executable (is that even possible?) –  ultrasawblade Nov 14 '11 at 12:30
@ultrasawblade AFAIK, only executable .sos can be loaded, and ld-linux is kind of important. –  Daniel Beck Nov 14 '11 at 12:41
add comment

No. At least, not in the same way. You are still executing a binary when you do the python thing. Python is +x. You would need to compile something that can load a file and execute it.

TiCL should make his/her response an answer because it is the best way to go.

share|improve this answer
Yeah, I understand "python" is a binary in that instance. What I was hoping for is that the "compile something that can load a file and execute it" already existed... –  Tom Sep 30 '11 at 1:35
@Tom You'll find C programs that can read an binary into memory and execute it. I don't know if Python is low level enough to do it in the C way, though. –  new123456 Sep 30 '11 at 1:52
add comment

Your Answer


