| CHMOD(1) | General Commands Manual | CHMOD(1) |
chmod — Change
files modes
chmod |
[-cRv] mode
file... |
chmod |
[-cRv] --reference
ref_file file... |
chmod sets the permissions bits given by
mode or copying permissions from
ref_file on each given file,
mode can be either an octal natural number
between 0 and 7777, or a symbolic operation like
‘+r’ or
‘g=o-x’. See the
OCTAL MODE and
SYMBOLIC OPERATIONS sections
for details.
If mode starts with a dash (or is user-provided), it should be broken from options with a preceding double-dash (--) like so:
chmod -v -- -w,+r foobar-c--reference
ref_file-R-vOctal natural number between 0 and 7777, which can be obtained by
or'ing the following values:
Uses the following grammar:
mode ::= clause [',' clause]* clause ::= who* action+ action ::= [op | op perm+ | op permcopy] who ::= 'u' | 'g' | 'o' | 'a' op ::= '+' | '-' | '=' perm ::= 'r' | 'w' | 'x' | 'X' | 's' | 't' permcopy ::= 'u' | 'g' | 'o'
Which corresponds to:
clause’ to apply, each
separated by a comma.
For example ‘g+r,o=g’
sets read permission for group part and copies to other part the
resulting permissions of the group part.
who’ and
contains one or more ‘action’.
When ‘who’ isn't given,
umask(3) is followed similarly to file
creation.
op’, optionally
followed by either one or more
‘perm’, or a single
‘permcopy’When neither ‘perm’ nor
‘permcopy’ were given, set(=)
clears all permissions.
The chmod utility exits 0 on
success, and >0 if an error occurs.
chmod should be compliant with the IEEE
Std 1003.1-2024 (“POSIX.1”) specification.
The -c, -v and
--reference options are present for compatibility
with other modern systems such as BusyBox and GNU coreutils.
The -c and -v
options were present in utils-std 0.0.1. The
--reference option was added in utils-std 0.0.2.
Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
| April 6, 2025 | Linux |