chmod】 改变一个文件或目录的模式【linux】


所有人增加执行权限 (myscript.sh)

chmod a+x myscript.sh

设置用户为读/写/执行,组/全局为只读(myscript.sh),符号模式

chmod u=rwx, go=r myscript.sh

从user/group/global(myscript.sh)中删除写入权限,符号模式

chmod a-w myscript.sh

移除user/group/global(myscript.sh)的读/写/执行权限,符号模式

chmod = myscript.sh

设置用户为读/写和组/全局读(myscript.sh),八进制记号

chmod 644 myscript.sh

设置用户为读/写/执行,组/全局为读/执行权限(myscript.sh),八进制记数法

chmod 755 myscript.sh

设置用户/组/全局为读/写权限(myscript.sh),八进制记数法

chmod 666 myscript.sh

角色

u - 用户 (文件的所有者)

g - 组 (文件组的成员)

o - 全局 (所有非所有者和非组员的用户)

a - 所有 (上述所有3个角色)

数字表示法

7 - 完全 (rwx)

6 - 读写 (rw-)

5 - 读+执行 (r-x)

4 - 只读 (r--)

3 - 写+执行 (-wx)

2 - 只写 (-w-)

1 - 只执行 (--x)

0 - 无 (---)

chmod】 Change the mode of a file or directory【linux】


Add execute for all (myscript.sh)

chmod a+x myscript.sh

Set user to read/write/execute, group/global to read only (myscript.sh), symbolic mode

chmod u=rwx, go=r myscript.sh

Remove write from user/group/global (myscript.sh), symbolic mode

chmod a-w myscript.sh

Remove read/write/execute from user/group/global (myscript.sh), symbolic mode

chmod = myscript.sh

Set user to read/write and group/global read (myscript.sh), octal notation

chmod 644 myscript.sh

Set user to read/write/execute and group/global read/execute (myscript.sh), octal notation

chmod 755 myscript.sh

Set user/group/global to read/write (myscript.sh), octal notation

chmod 666 myscript.sh

Roles

u - user (owner of the file)

g - group (members of file's group)

o - global (all users who are not owner and not part of group)

a - all (all 3 roles above)

Numeric representations

7 - full (rwx)

6 - read and write (rw-)

5 - read and execute (r-x)

4 - read only (r--)

3 - write and execute (-wx)

2 - write only (-w-)

1 - execute only (--x)

0 - none (---)


腾图小抄 SCWY.net v0.03 小抄561条 自2022-01-02访问247794次