I am shocked that I still don't understand "Execute" permission in Linux.

There are three permission - read, write, and execute. I understand that read and write literally, but what does execute do exactly?

Let's say I have example.php with execute permission. What can I do with example.php?


4 Answers 4


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




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


instead of having to do

python ./script
  • 1
    What does this mean for non text-based filetypes eg. .png or .avi?
    – iono
    Jul 17, 2014 at 6:10
  • 1
    Basically the same, the file extension doesn't matter. If you have #!/bin/bash at the beginning of your .avi file, it will be executed as bash. If it is a real avi format, you probably won't be able to run it because interpreting it as commands will not make sense and fail.
    – Mifeet
    Aug 19, 2015 at 14:19
  • Is the #! really interpreted by the kernel?
    – masterxilo
    Dec 21, 2017 at 12:50
  • Execute permissions have a different meaning on directories: unix.stackexchange.com/questions/21251/…
    – LawrenceC
    Nov 13, 2020 at 20:51
  • @masterxilo: Yes. The exec functions--which are Linux system calls--look for the #! and call the specified interpreter. More details here:
    – LawrenceC
    Nov 13, 2020 at 20:55

"execute" allows the user to execute executables. For directories it is the allowance to enter the directory using the cd command.

  • 1
    That access to directory part is huge. You would never guess that just from the name of mode itself.
    – oldboy
    Mar 24, 2018 at 4:11

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.

  • 1
    This actually makes a lot of sense.
    – masterxilo
    Dec 21, 2017 at 12:58
  • I had a confusion with READ/EXECUTE, and expected such answer. thanks
    – T.Todua
    Jun 23, 2019 at 19:42

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, like dir1/prog1 or ./prog2.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.