9 thoughts on “When you try to run a command as sudo but it says permission denied

  1. If you get permission denied when trying to run a script via sudo, you should probably check the x bit.

  2. 1. Filesystem mounted noexec
    2. x permission bit not set on executable file
    3. Default sudo user set to a user without permission
    4. Trying to redirect to a protected file from a non-elevated shell
    5. selinux mode set to enforcing and file context does not permit execution
    6. Executable is setuid/setgid to something that doesn’t have permission
    7. It’s a script and any of the above actually apply to the application in the shebang

    Any more?

  3. Probably because you’re trying to redirect something and not using a root shell. So the shell replies back “No, you’re not!”.

Leave a Reply

Your email address will not be published. Required fields are marked *