如何将文件设置为不可执行?

dec*_*off 7 linux command-line chmod

我想关闭 Linux 可执行文件的可执行位。我知道我可以设置a+x使其可执行,但我不能将其设置为不可执行。

谷歌从搜索中省略了“不是”。

Ish*_*shi 20

仅供参考。

CHMOD 用于更改文件的权限。权限命令

     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
Run Code Online (Sandbox Code Playgroud)

这是另一种看待它的方式:

权限:

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
Run Code Online (Sandbox Code Playgroud)

要获得组合,只需将它们相加即可。例如,要读取、写入、由所有者执行、读取、执行、按组和由任何人执行,您将添加 400+200+100+040+010+001 得到 751。


Hen*_*nes 16

无需更改其他设置的最简单方法:chmod -x file.

来自 man chmod:

           模式 ::= 子句 [, 子句 ...]
           子句 ::= [谁 ...] [动作 ...] 动作
           动作 ::= op [烫发 ...]
           谁 ::= 一个 | 你| 克 | ○
           操作 ::= + | - | =
           烫发::= r | | 吨| | | × | X | 你| 克 | ○

注意op : 中的三个选项,和+-=


Pet*_*ter 10

只需使用: chmod -x <file>


小智 10

就像 a+x 添加 execute 一样,ax 删除它。