Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Mar 9 '10 at 0:14

This question came from our site for professional and enthusiast programmers.

3 Answers 3

up vote 17 down vote accepted

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, write access would allow you to modify it, read access would allow you to view 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

share|improve this answer
    
What does this mean for non text-based filetypes eg. .png or .avi? –  iono Jul 17 at 6:10

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

share|improve this answer
4  
+1 for permission effect on a directory –  JannieT Jan 21 '12 at 10:06

It's for running apps from gui or command line. For "normal" php use (via webserver) that doesn't change anything. Precisely speaking it depend on configuration, but in most common cases You don't need +x permission to allow loading your php webpage via browser).

For running from commend line You need:

  • add #!/usr/bin/php at the script beginning
  • add +x permission
  • Your script mast be in executable search path ($PATH environment variable) or You have to use ./ before your script name
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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