Execute file permission on data files

I'm not much of a terminal/Unix user but I've been looking at some folders and files within my Documents and Movies default directories that are in my OS X home directory. I notice that permissions on my files vary when invoking the ls -l command and looking at the results


I find it difficult to understand if there is any reason if the execute permission makes any difference whatsoever on a data files (ie. movie, Excel doc, .txt file, Word doc, music, picture, etc.). For some reason some of my Excel files will have the following -rwxr-xr-x whereas others will be -rw-r--r-- (the same goes with some movie files, that's as far as I looked). As far as I can tell making changes with Get Info in Finder has no affect on Owner and Group (with regards to execute) and only with Other can you set permissions to "No Access" that will get rid of the execute permission. Of course I can use the chmod command to modify these files, however, my question revolves around the first sentence of this paragraph:


Does the execute permission have any effect on data files and is there any reason to remove such permissions? Without looking at the terminal window it appears OS X from Finder/Get Info only differentiates between read and write.


I imagine the differences I see stem from saving files over many years in various operating systems (Windows, Linux, and Mac OS X) and eventually consolidating them on my Mac. That is just a hunch. If I create a new file in Excel and save it I get the following in Terminal -rw-r--r--@



MacBook Pro, Mac OS X (10.6.7), 4 GB of RAM

Posted on Jun 14, 2011 5:52 AM

Reply
3 replies

Jun 14, 2011 6:52 AM in response to TT Mac

You can interact with files using the Finder or using UNIX things like the shell or through scripts.


For Finder, the execute permission on data files is ignored if Finder can otherwise figure out what type of file it is. If Finder doesn't know what file it is (by extension or by file type), then if there are execution permissions set for it the file it assigns the file a type of "UNIX Executable".


From the standpoint of the UNIX ways of interacting with files (scripts/the shell), the execute permission does indicate whether or not UNIX should treat the file as something executable or not. If it's on, and you refer to a file in a way that would indicate that you're trying to execute it, then it will check if you have execute permission. If so, it will first check to see if the file is a text file or a binary file. If binary, it attempts to load and run it as a program. If text, it treats it as a script. If it thinks it's a script, it checks the first like to see if there's a comment that starts with '#!' followed by the path to an executable file -- if so, it will start that executable and feed the text of the script to it (in this way, you can specify what interpreter to use to execute the script), otherwise '/bin/sh' the current shell ('/bin/bash' by default) is used.


Note that directories have executable bits too. If you do not have execute permissions for a directory, you cannot enter that directory.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Execute file permission on data files

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.