Permissions

Linux chmod command

Change file permissions. This example grants the owner execute permission.

Availability: Common Linux commands; shell built-ins and external implementations may differ by distribution.中文

Syntax

chmod [OPTION]... MODE FILE...

Examples

Add execute permission for the owner.

chmod u+x ./script.sh

Set owner read/write and group read permissions.

chmod 640 ./secrets.txt

Parameters, options and clauses

Option / clauseDescription
MODE (symbolic)Use forms such as u+x, go-w or a=rx.
MODE (numeric)Use octal digits such as 640 or 755.
-R, --recursiveChange permissions recursively (directories and contents).
-v, --verboseReport every processed file.
-c, --changesReport only files whose permissions changed.
-f, --silentSuppress most error messages.
--reference=FILEUse FILE's mode instead of MODE.
Safety note

Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.

Official reference ↗Back to directory