Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 or python

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
up vote 27 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/ /tmp/ls

The actual name differs from architecture to architecture. Some names include /lib/, /lib/ and /lib/ 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/ isn't executable (is that even possible?) – LawrenceC 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
On 64-bit Ubuntu it is /lib64/ – Tor Klingberg Jul 14 at 10:12

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .