Server Fault is a question and answer site for system and network administrators. 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

I'm just curious.

bash-3.00$  ldd
ldd: warning: you do not have execution permission for `'

Everything seems to work fine just with +r. I noticed that most of the .so's in /usr/lib do have +x set...

Why shared libs are supposed to have executable bit set? What could happen if I don't set it?

share|improve this question
Libraries definitely don't need +x to run properly. Perhaps they're links however? Links would need +x to be followed. – Chris S Aug 24 '10 at 13:56
Yes, they don't need +x, yet most of the libraries has it set. – Tomo Aug 24 '10 at 20:09
This question has also been asked on Unix&Linux:… (and got the correct answer there) – Michał Górny Jul 18 at 5:09
up vote 3 down vote accepted

Actually it depends on the ldd implementation. ldd is usually a script, you can edit it to see where and why you get that error.

On Ubuntu 10.04, ldd checks for the read permission only. It may give the error not a dynamic executable if the file is not a ELF (Executable and Linkable Format). The libs here are all -rw-r--r--, for instance

$ find /usr/lib -type f -name "libm*.so*" -ls
-rw-r--r--   1 root     root       216800 Feb 26 22:20 /usr/lib/
-rw-r--r--   1 root     root        76728 Mar 14 04:23 /usr/lib/
-rw-r--r--   1 root     root       134464 Jan 29  2010 /usr/lib/
-rw-r--r--   1 root     root       290480 Feb 17  2010 /usr/lib/

It isn't shocking to want an x access for a shared library. The executable mode is a convention that gives the OS another level of access rights control. The executable loader controls that access, to ensure the user can execute it, but also to prevent errors (some scripts or programs should not be executed by some people).

This could be extended to the shared libraries for the same reason - but shared libraries cannot run by themselves, and are less error prone to be used by accident). Thus the need is less obvious (the r access suffices).

share|improve this answer

You can actually execute a lot of libraries, see for example what happens when you type /lib/ at your shell on a recent GNU/Linux system.

share|improve this answer

think like having an executable file with -x. You won't be able to execute it. Consider these libraries as a collection of general functions, that are being called by another program (let's say myProgra). If you cannot execute the libraries / function ... then you have nothing

An example

function1() {} 
function2() {} 
int main() { 
printf("Let's call func1"); 
printf("Let's call func2"); 

Now if you place function1 and function2 in another file and you include it, then you a library. (Of course it's something more complicated. This is just an example)

But in any case, as you can see, you have to execute the code that is being included in the library

share|improve this answer
But you execute executables, not libraries. – Ignacio Vazquez-Abrams Aug 24 '10 at 12:16
See the edited version above – Nikolaidis Fotis Aug 24 '10 at 12:46

The key is the file format, Executable and Linkable Format. Since the same exact file format is used to identify both an executable and a shared library, both must have the appropriate executable permissions for the OS loader. This allows for a single loader and for executables to be used as a DSO if they include a symbol table.

share|improve this answer
So, the loader uses permission bits, not the file header, to identify things to load? – Tomo Aug 24 '10 at 20:09
The loader uses the file header to identify the contents as DYN or EXEC and do the appropriate thing. The execute bit is for the OS, not the loader. ELF is an executable format, without the execute bit, the OS won't allow the loader to execute the file in order to read the headers. Check out wikipedia for more on ELF – nzwulfin Aug 25 '10 at 12:40

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.