How to set a file as NOT executable?

5

6

I want to toggle off the executable bit of a Linux executable. I know that I can set a+x to make it executable, but I can't set it as not executable.

Google omits "not" from searches.

deckoff

Posted 2013-01-24T15:20:58.233

Reputation: 221

Answers

14

Just FYI.

CHMOD is used to change permissions of a file. PERMISSION COMMAND

     U   G   W
    rwx rwx rwx     chmod 777 filename      
    rwx rwx r-x     chmod 775 filename
    rwx r-x r-x     chmod 755 filename
    rw- rw- r--     chmod 664 filename
    rw- r-- r--     chmod 644 filename

    U = User 
    G = Group 
    W = World

    r = Readable
    w = writable
    x = executable 
    - = no permission

Here is another way of looking at it:

Permissions:

400     read by owner
040     read by group
004     read by anybody (other)
200     write by owner
020     write by group
002     write by anybody
100     execute by owner
010     execute by group
001     execute by anybody

To get a combination, just add them up. For example, to get read, write, execute by owner, read, execute, by group, and execute by anybody, you would add 400+200+100+040+010+001 to give 751.

Ishikawa Yoshi

Posted 2013-01-24T15:20:58.233

Reputation: 825

13

Easiest way without changing other settings: chmod -x file.

From man chmod:

           mode         ::= clause [, clause ...]
           clause       ::= [who ...] [action ...] action
           action       ::= op [perm ...]
           who          ::= a | u | g | o
           op           ::= + | - | =
           perm         ::= r | s | t | w | x | X | u | g | o

Notice the three options in op: +, - and =

Hennes

Posted 2013-01-24T15:20:58.233

Reputation: 60 739

9

Simply use: chmod -x <file>

Peter

Posted 2013-01-24T15:20:58.233

Reputation: 1 157

9

Just like a+x adds execute, a-x removes it.

bplattenburg

Posted 2013-01-24T15:20:58.233

Reputation: 191