chmod 权限管理速查表

把 Linux 文件权限管理最常用的命令整理成速查表,配置权限时对照查。

系统与运维·共 30 条命令·最后更新 2026-07-19
返回 系统与运维

权限说明 Permission Bits 6

r (read)
读权限,数字 4
w (write)
写权限,数字 2
x (execute)
执行权限,数字 1
- (no permission)
无权限,数字 0
u g o
用户(owner)/ 组(group)/ 其他(others)
a
所有(all),等价于 ugo

数字模式 Numeric Mode 6

chmod 755 file
rwxr-xr-x(所有者全权限,其他人读执行)
chmod 644 file
rw-r--r--(所有者读写,其他人只读)
chmod 700 file
rwx------(仅所有者有全权限)
chmod 600 file
rw-------(仅所有者读写,常用于私钥)
chmod 777 file
rwxrwxrwx(所有人全权限,危险!)
chmod 750 dir
rwxr-x---(所有者全权限,组读执行)

符号模式 Symbolic Mode 6

chmod u+x file
给所有者加执行权限
chmod go-w file
给组和其他人去写权限
chmod a+r file
给所有人加读权限
chmod u=rw,go=r file
设置所有者读写,其他人只读
chmod +x script.sh
给所有人加执行权限(省略 ugo 默认 a)
chmod -R 755 dir/
递归修改目录权限

特殊权限 Special Permissions 6

chmod u+s file (4755)
SUID:执行时以所有者身份运行
chmod g+s dir (2755)
SGID:目录内新建文件继承组
chmod +t dir (1777)
Sticky:仅所有者可删除文件(如 /tmp)
chmod 4755 file
数字模式设置 SUID
chmod 2755 dir
数字模式设置 SGID
chmod 1777 dir
数字模式设置 Sticky

常见权限组合 Common Patterns 6

644
普通文件(所有者读写,其他人只读)
755
可执行文件和目录
600
私钥文件(SSH、SSL)
640
配置文件(所有者读写,组只读)
700
私有目录(仅所有者访问)
750
共享目录(所有者全权限,组读执行)

💡 提示

  • chmod 数字模式:r=4, w=2, x=1,相加得到权限值(如 rwx = 4+2+1 = 7)。
  • 目录的 x 权限表示可以进入(cd),没有 x 权限即使有 r 也进不去。
  • SUID 对脚本无效(只对二进制可执行文件),且存在安全风险,谨慎使用。