chmod 权限管理速查表
把 Linux 文件权限管理最常用的命令整理成速查表,配置权限时对照查。
返回 系统与运维权限说明 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 filerwxr-xr-x(所有者全权限,其他人读执行)
chmod 644 filerw-r--r--(所有者读写,其他人只读)
chmod 700 filerwx------(仅所有者有全权限)
chmod 600 filerw-------(仅所有者读写,常用于私钥)
chmod 777 filerwxrwxrwx(所有人全权限,危险!)
chmod 750 dirrwxr-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 对脚本无效(只对二进制可执行文件),且存在安全风险,谨慎使用。