Online Linux Terminal Logo
OnlineLinuxTerminal
权限与安全CLI Manual

$chmod

更改所有者、用户组及其他用户的 Linux 文件读写执行权限。

命令语法POSIX Standard
chmod [OPTIONS] MODE[,MODE]... FILE...
Linux 社区2.4k 在线

与真实 Linux 用户交流,学习常用命令并免费获取精美速查表 PDF。

在交互式终端沙盒中实时运行

无需安装的客户端实时仿真环境。

在全屏终端工作区中打开 ↗
bash — terminal

概述与工作原理

chmod 命令用于配置 Linux 系统的文件与目录权限模式,精准控制读取(r)、写入(w)与执行(x)权限。

常用参数与选项说明

Flag / OptionDescription
755rwxr-xr-x: Owner has full control; group and others can read and execute.
644rw-r--r--: Owner can read and write; group and others can read only.
700rwx------: Owner has full control; no access for anyone else.
-RRecursively change file permissions on all subdirectories and files.
+xMake a script or binary file executable for all users.

实际生产案例与代码范例

#1Make a bash script executable
chmod +x /home/user/projects/demo.sh && ls -l /home/user/projects/demo.sh

Adds execute permissions to demo.sh and verifies the updated mode bits.

#2Set standard web file permissions (644)
chmod 644 /var/log/syslog

Grants read/write to owner and read-only to group and others.