chmod.1 (3258B)
- .\" utils-std: Collection of commonly available Unix tools
 - .\" Copyright 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
 - .\" SPDX-License-Identifier: MPL-2.0
 - .Dd April 6, 2025
 - .Dt CHMOD 1
 - .Os
 - .Sh NAME
 - .Nm chmod
 - .Nd Change files modes
 - .Sh SYNOPSIS
 - .Nm
 - .Op Fl cRv
 - .Ar mode
 - .Ar file...
 - .Nm
 - .Op Fl cRv
 - .Fl -reference Ar ref_file
 - .Ar file...
 - .Sh DESCRIPTION
 - .Nm
 - sets the permissions bits given by
 - .Ar mode
 - or copying permissions from
 - .Ar ref_file
 - on each given
 - .Ar file ,
 - .Pp
 - .Ar mode
 - can be either an octal natural number between 0 and 7777,
 - or a symbolic operation like
 - .Ql +r
 - or
 - .Ql g=o-x .
 - See the
 - .Sx OCTAL MODE
 - and
 - .Sx SYMBOLIC OPERATIONS
 - sections for details.
 - .Pp
 - If
 - .Ar mode
 - starts with a dash (or is user-provided),
 - it should be broken from options with a preceding double-dash
 - .Pq --
 - like so:
 - .Dl chmod -v -- -w,+r foobar
 - .Sh OPTIONS
 - .Bl -tag -width Ds
 - .It Fl c
 - Print mode changes
 - .It Fl -reference Ar ref_file
 - Copy permission bits from
 - .Ar ref_file
 - into each
 - .Ar file .
 - .It Fl R
 - Recurse into directories passed to
 - .It Fl v
 - Verbose, print both changes and retained modes
 - .Ar file
 - .El
 - .Sh OCTAL MODE
 - Octal natural number between 0 and 7777,
 - which can be obtained by or'ing the following values:
 - .br
 - .Bl -tag -width 0000 -compact
 - .It 4000
 - setuid
 - .It 2000
 - setgid
 - .It 1000
 - sticky bit
 - .It 0400
 - user read
 - .It 0200
 - user write
 - .It 0100
 - user execute/search
 - .It 0070
 - group read, write, execute/search
 - .It 0007
 - others read, write, execute/search
 - .El
 - .Sh SYMBOLIC OPERATIONS
 - Uses the following grammar:
 - .Bd -literal
 - 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'
 - .Ed
 - .Pp
 - Which corresponds to:
 - .Bl -tag -width permcopy
 - .It mode
 - List of
 - .Ql clause
 - to apply, each separated by a comma.
 - .Pp
 - For example
 - .Ql g+r,o=g
 - sets read permission for group part and
 - copies to other part the resulting permissions of the group part.
 - .It clause
 - Optionally starts with
 - .Ql who
 - and contains one or more
 - .Ql action .
 - .Pp
 - When
 - .Ql who
 - isn't given,
 - .Xr umask 3
 - is followed similarly to file creation.
 - .It action
 - Always starts with
 - .Ql op ,
 - optionally followed by either one or more
 - .Ql perm ,
 - or a single
 - .Ql permcopy
 - .It who
 - user(u), group(g), other(o), all(a)
 - .It op
 - Operation to apply: add(+), del(-), set(=)
 - .Pp
 - When neither
 - .Ql perm
 - nor
 - .Ql permcopy
 - were given, set(=) clears all permissions.
 - .It perm
 - which permissions to assign:
 - .Bl -tag -width X -compact
 - .It r
 - Read
 - .It w
 - Write
 - .It x
 - Execute/Search
 - .It X
 - Search (directories-only)
 - .It s
 - Setuid when assigned to user, setgid when assigned to group
 - .It t
 - Sticky bit
 - .El
 - .It permcopy
 - who to copy permissions from: user(u), group(g), other(o)
 - .El
 - .Sh EXIT STATUS
 - .Ex -std
 - .Sh SEE ALSO
 - .Xr stat 1
 - .Sh STANDARDS
 - .Nm
 - should be compliant with the
 - IEEE Std 1003.1-2024 (“POSIX.1”)
 - specification.
 - .Pp
 - The
 - .Fl c ,
 - .Fl v
 - and
 - .Fl -reference
 - options are present for compatibility with other modern systems such as
 - BusyBox and GNU coreutils.
 - .Sh HISTORY
 - The
 - .Fl c
 - and
 - .Fl v
 - options were present in utils-std 0.0.1.
 - The
 - .Fl -reference
 - option was added in utils-std 0.0.2.
 - .Sh AUTHORS
 - .An Haelwenn (lanodan) Monnier Aq Mt contact+utils@hacktivis.me