Thursday, November 11, 2021

[SOLVED] How do I chmod a file and have it persist across multiple machines when I transfer it?

Issue

There's a .sh script that I want to let an entire team be able to use on their own machines. Then I noticed that I needed to chmod +x thescript.sh on the file every time the script is newly downloaded into the machine.

Is there a way so that the +x permission is persistent even when uploading it so I don't need to keep chmod'ing?

EDIT: To clarify, the +x permission doesn't get carried over when I attach it to an email and it's then downloaded to a different machine. I haven't tried uploading it in general, but I'm assuming it would have the same behavior.


Solution

In security terms, persisting +x would allow viruses to do their thing.

As an alternative, set the correct permissions on the file and then create a zip or tar archive. Unzipping will preserve the file permissions.



Answered By - John Hanley