Search code examples
ubuntufile-permissionschmod

'Permission denied' issue when executing a file downloaded from Github


I have compiled a program on my Ubuntu 16.04. When

ls -l <filename> 

is run, it produces the following output on my computer which suggests that anybody can execute this file(i guess?) -

-rwxr-xr-x 1 ritwik ritwik 10132280 May  4 12:44 <filename>

Then I uploaded this file to github. Now, when someone downloads this file from my github repo and executes it on their computer, it throws the 'Permission Denied' error. However, when they run -

chmod u+x <filename>

and then execute the file, no such error occurs.

How can I change permissions before uploading so that the users do not have to change the permissions themselves (do not have to do that chmod thing) ?


Solution

  • This is not directly possible, since when you download a file, it gets created on the recipients machine and then filled by what arrives over the network.

    You can make a tar(1) archive. This preserves the execute bit and when the recipient extracts it, the tar binary will set the x bit again.