← 返回命令列表

Linux command

chmod 命令

安全

权限或系统影响较大,执行前请核对目标。

常用示例

Make

chmod +x [script.sh]

Set

chmod 755 [file]

Remove

chmod -w [file]

Recursive

chmod -R 755 [directory/]

Set

chmod u=rwx,g=rx,o=r [file]

说明

chmod (change mode) modifies file access permissions. It controls read, write, and execute permissions for three classes of users: the file owner (user), the file's group, and all other users. Permissions can be specified in two ways: numeric (octal) mode using digits 0-7, or symbolic mode using letters (u/g/o/a, +/-/=, r/w/x). Numeric mode sets all permissions at once, while symbolic mode allows adding or removing individual permissions. The command is fundamental to Unix file security and access control.

参数

-R, --recursive
Change files and directories recursively
-v, --verbose
Verbose output
-c, --changes
Report only changes
--reference=_file_
Use permissions from reference file

FAQ

What is the chmod command used for?

chmod (change mode) modifies file access permissions. It controls read, write, and execute permissions for three classes of users: the file owner (user), the file's group, and all other users. Permissions can be specified in two ways: numeric (octal) mode using digits 0-7, or symbolic mode using letters (u/g/o/a, +/-/=, r/w/x). Numeric mode sets all permissions at once, while symbolic mode allows adding or removing individual permissions. The command is fundamental to Unix file security and access control.

How do I run a basic chmod example?

Run `chmod +x [script.sh]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -R, --recursive do in chmod?

Change files and directories recursively