Why Linux File Permissions Failed?

Hello Kodekloud Community,
Please see the output i have chmod 111 permission to the file. The file is executable, see image below and than also the task failed.

kode

Same result bro

I would request the team to check this issue. And would request you to revert back if i am not wrong as it adds a failed task to my profile.

you did incorrect. You have to apply only ( chmod +x “filename” ) because you used chmod 111 that is not a good practice. You changed default permissions of that file. You gave execution permission but first system read the file then perform execution. Hope it will help you.

regards,

1 Like

Hello,

Thank you for reporting this. Since its a bash script not a normal file so it is asked to give it executable permission so that server users can run the script later whenever needed.

Please note that in case of bash script bash is the interpreter that is actually going to execute the script and the interpreter needs to read the script so even if you have given it only executable permission the interpreter i.e bash will not be able to execute it so you had to give it read permission as well along with execute permission.

Just for reference: permissions - Can a script be executable but not readable? - Unix & Linux Stack Exchange

But we can see how its bit confusing since there is no mention about the users who should be able to execute it, so we have modified the question a little, We hope it is more clear now.

2 Likes

Thank you for your detailed explanation. I think the the question was bit confusing to all. Would request if you could waive off this time, as a lot of people are having this same issue.

Hello,

Since we have made some improvement in this question to make it more clear so we marked this task as Pending for all who failed it. So all of them can give it another try.

1 Like

Thanks @Inderpreet Would give my best shot

hey guys,

i too used chmod +x xfusioncorp.sh , but it said task failed . So i executed chmod 777 xfusioncorp.sh . Please let me know if this is correct

file permission

@kaushik You are not allowed to change the default permissions of the file. Giving chmod 777 will change the scenario completely. The correct way is to give read and execute permissions only.

yes thats right since it said failed i re tried with 777 option :slight_smile:

Screen Shot 2020-03-12 at 7.49.59 PM
I thought the goal was to make this file executable.
Would someone help me out, please? What did I miss?

Yes, goal is to make it executable so that all users on that server can run the script as asked in the question. With the permissions you have given only root or sudo users will be able to execute this script but not any other normal user hence task was marked as failed.

2 Likes

Ah, I need to read the instructions more carefully. Thanks, Inderpreet!