1

I'm running my server as a root user but despite that, when I run the command ls I get this error:

bash: /bin/ls: Permission Denied.

I tried to change this file's permissions with chmod but the permission is denied as well. What's the cause of this?

  • Silly question, but kind of mandatory when running Linux. Have you tried sudo ls? – Reaces May 12 '14 at 15:47
  • 2
    Is it possible that your filesystem was mounted with -o noexec? Or does not support the executable flag which would tell Linux that a file is executable (e.g. NTFS)? – fNek May 12 '14 at 16:00
  • 2
    When you changed the /bin/ls file's permissions, what did you change them from and what did you change them to? – Ladadadada May 12 '14 at 16:27
  • 1
    You're probably going to have to boot from rescue media and fix enough permission to make the system manageable. – David Schwartz May 13 '14 at 2:17
5

There are several potential causes for this.

  1. The filesystem is mounted noexec.
  2. Filesystem corruption that needs to be fixed with fsck.
  3. The filesystem is foreign and improper translation of permissions results in denied privileges.
  4. The directory holding the binary does not have the execute bit set (causing an issue with traversal)
  5. A sub-directory in the directory does not have the execute bit set (only applies if the binary is nested in more than one directory)
  6. The binary does not have the read and execute bits set for your user ID or group ID.
  7. You are not really root (UID 0), even though the account name says root. While improbable, this is possible. Note that root is not 100% the same as UID 0, which is a "special" ID that bypasses privilege checks. The root account, however, is mapped to UID 0.
  8. SELinux/grsecurity rules denying everything. (thanks Janne Pikkarainen! had a little mental block about that annoyance.)
  9. One or more binaries are compromised. In which case, you can't trust anything you are running.

More information is needed to really understand what is happening.

  • 2
    Could you please elaborate why a read only filesystem would result in that error (I think that is plain wrong as I have run a couple of systems with solely RO mounted partitions and everything works as expected -- I'd think you wanted to write noexec instead of read-only) – serverhorror May 12 '14 at 21:05
  • noted and fixed. – Avery Payne May 12 '14 at 23:52
  • 1
    9. SELinux/grsecurity rules denying everything. – Janne Pikkarainen May 13 '14 at 5:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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