3

I want to grant execute permission for a script, but not read permission since I do not want user to read the content for the script. But it seems not working, I post what I am doing and seeking for advice,

sub-directory demo is owned by root user and root group,

Case 1, make execute+read permission, works

chmod 775 /home/yhd/demo/text

Then user yhd can execute text command without any issues

Case 2, make execute permission only, not working

chmod 771 /home/yhd/demo/text

Then user yhn cannot execute text command, and error message is permission denied

4

The problem with scripts is that the script is not what is running, but the interpreter (bash in this case).

The interpreter needs to read the script.

Since reading the file is forbidden then it can't be executed inside the interpreter.

This is different from a program, because programs are loaded directly into the kernel.

One solution is to use a compiler that will generate a C program equivalent to the script, like SHC, that you can download from here or from this guide.

  • Thanks for all the help jcbermu, mark your reply as answered. – Lin Ma Feb 23 '16 at 3:47
3

how to grant execute permission without read permission?

Nope, is not possible: the interpreter needs to read script. What @jcbermu means is this one: https://unix.stackexchange.com/questions/34202/can-a-script-be-executable-but-not-readable

  • 1
    Vote up nice reply. Thanks for all the help duDE, nice name. :) – Lin Ma Feb 23 '16 at 3:47

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.