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?

Ladadadada
  • 26,337
  • 7
  • 59
  • 90
user219442
  • 11
  • 2
  • 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)? – elaforma 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 02:17

1 Answers1

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.

Avery Payne
  • 14,536
  • 1
  • 51
  • 88