What does the "execute" permission do?
Solution 1:
Basically it means you can tell the operating system to run the code in the file. For example, if the file was a binary executable, read access would allow you to view it, write access would allow you to modify it, but without execute permissions you would not be able to run the program. In the case of a script, its a little more complicted, because you don't necessarily need to 'run' the program, you can just read its contents into an interpreter, which itself has the execute privelige, but you do not need execute permissions on the script itself.
Some scripts in Linux are themselves executable, you will often see a line at the top like
#!/bin/bash
or
#!/bin/python
That line tells the kernel that the file can be executed by calling the relevant program (and isn't just text). Then you can just run your script like
./script
instead of having to do
python ./script
Solution 2:
"execute" allows the user to execute executables. For directories it is the allowance to enter the directory using the cd command.
Solution 3:
For practical purposes, permission to read implies ability to execute.
However the opposite is not true; there is some value in the ability to give permission to execute code without giving permission to read it.
Solution 4:
It's for running apps from GUI or command line. For "normal" php use (via webserver), that doesn't change anything. Precisely speaking, it depends on configuration, but in most common cases you don't need +x permission to allow loading your php webpage via browser.
For running from command line you need:
- add
#!/usr/bin/php
at the script beginning - add +x permission
- your script must be in your executable search path
($PATH environment variable)
or you have to specify the directory that it is in before your script name.
This could be an absolute pathname, like
/etc/xdg/foo
or/home/fred/bar
, or a relative directory, likedir1/prog1
or./prog2
.