Possible Duplicate:
Why are shared libraries executable?

Why do the .so files in /lib have permission 755 and not 644 in Linux? That seems strange

According to http://www.gossamer-threads.com/lists/gentoo/user/231943, it seems for old glibc. On my embedded system /lib/libc.so.6 it works even permission is 644.


2 Answers 2


I suspect it's probably just for historical reasons.

BlueBomber's answer is probably historically correct, but it's not actually necessary for shared objects to be executable.

On my Ubuntu system, they aren't. Of the 30 /lib/*.so* and 600 /usr/lib/*.so* files, only one has execute permissions, and that's probably just a glitch.

Execute permission permits a file to be executed via one of the exec*() functions; shared object files contain executable code, but they're not executed in that way.

On the other hand, on a CentOS 5.7 system I have access to, those files are executable; the same is true on a SPARC Solaris 9 system. (It would be interesting to try turning off executable permissions on some of those files to see if it breaks anything, but I'm not able to do so.)

(What Linux distribution are you using?)


This answer to this question shows an example (HP-UX) of a system where the execute bit is actually required. That doesn't appear to be the case on Linux, where some distributions set the execute bit (probably out of historical inertia) and others don't. Or maybe some Linuxes actually require it.

Another data point: On my Ubuntu system, I just tried creating my own shared object file. The generated "libfoo.so" file was created with execute permissions, but if I manually chmod -x it, the program that uses it still works.

In any case, setting execute permission on *.so files is Mostly Harmless (and certainly less annoying that, say, setting execute permission on source files).


As fwyzard points out in a comment, some *.so files can actually be executed. For example, on my current system, executing /lib/x86_64-linux-gnu/libc-2.27.so prints version information for the GNU C library. /lib/x86_64-linux-gnu/libpthread-2.27.so behaves similarly.

  • 1
    AFAIK, only libc.so.6 has a use for the execute bit, in that you can actually execute it: running /lib/x86_64-linux-gnu/libc.so.6 will print its version information, e.g. "GNU C Library (Ubuntu GLIBC 2.27-3ubuntu1) stable release version 2.27."
    – fwyzard
    Dec 5, 2019 at 10:06
  • 1
    Another use case. You can use /lib64/ld-linux-x86-64.so.2 to execute ELF executables that do not have the execute permission bit set. e.g., cp /bin/ls /tmp/ls; chmod 0600 /tmp/ls; /lib64/ld-linux-x86-64.so.2 /tmp/ls.
    – doneal24
    Dec 5, 2019 at 17:22

If I understand your question, you are asking why shared object files have execute permissions, and that's because those are library files intended to be linked, and the code they contain is intended to be executed.


  1. http://www.gossamer-threads.com/lists/gentoo/user/231943

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