xref: /csrg-svn/bin/chmod/chmod.1 (revision 50181)
143082Scael.\" Copyright (c) 1989, 1990 The Regents of the University of California.
239829Sbostic.\" All rights reserved.
319384Smckusick.\"
4*50181Sbostic.\" This code is derived from software contributed to Berkeley by
5*50181Sbostic.\" the Institute of Electrical and Electronics Engineers, Inc.
6*50181Sbostic.\"
742527Sbostic.\" %sccs.include.redist.man%
839829Sbostic.\"
9*50181Sbostic.\"     @(#)chmod.1	6.14 (Berkeley) 06/27/91
1039829Sbostic.\"
1143082Scael.Dd
1243082Scael.Dt CHMOD 1
1343082Scael.Os BSD 4.4
1443082Scael.Sh NAME
1543082Scael.Nm chmod
1647089Scael.Nd change file modes
1743082Scael.Sh SYNOPSIS
1843082Scael.Nm chmod
1947089Scael.Op Fl R
2043082Scael.Ar mode
2143082Scael.Ar file ...
2243082Scael.Sh DESCRIPTION
2339829SbosticThe
2443082Scael.Nm chmod
2539829Sbosticutility modifies the file mode bits of the listed files
2639829Sbosticas specified by the
2743082Scael.Ar mode
2839829Sbosticoperand.
2943082Scael.Pp
3039829SbosticThe options are as follows:
3147089Scael.Bl -tag -width Ds
3247089Scael.It Fl R
3339829SbosticTraverse a file hierarchy.
3439829SbosticFor each file that is of type directory,
3543082Scael.Nm chmod
3639829Sbosticchanges the mode of all files in the file hierarchy below it followed
3739829Sbosticby the mode of the directory itself.
3847089Scael.El
3943082Scael.Pp
4039829SbosticSymbolic links are not indirected through, nor are their modes altered.
4143082Scael.Pp
4239829SbosticOnly the owner of a file or the super-user is permitted to change
4339829Sbosticthe mode of a file.
4443082Scael.Pp
4539829SbosticThe
4643082Scael.Nm chmod
4739829Sbosticutility exits 0 on success, and >0 if an error occurs.
4843082Scael.Sh MODES
4939829SbosticModes may be absolute or symbolic.
5039829SbosticAn absolute mode is an octal number constructed by
5147089Scael.Ar or Ap ing
5239829Sbosticthe following values:
5347089Scael.Pp
5447089Scael.Bl -tag -width 6n -compact -offset indent
5547089Scael.It Li 4000
5639829Sbosticset-user-ID-on-execution
5747089Scael.It Li 2000
5839829Sbosticset-group-ID-on-execution
5947089Scael.It Li 1000
6039829Sbosticsticky bit, see chmod(2)
6147089Scael.It Li 0400
6219384Smckusickread by owner
6347089Scael.It Li 0200
6419384Smckusickwrite by owner
6547089Scael.It Li 0100
6639829Sbosticexecute (or search for directories) by owner
6747089Scael.It Li 0070
6839829Sbosticread, write, execute/search by group
6947089Scael.It Li 0007
7039829Sbosticread, write, execute/search by others
7147089Scael.El
7243082Scael.Pp
7339829SbosticThe read, write, and execute/search values for group and others
7439829Sbosticare encoded as described for owner.
7543082Scael.Pp
7639829SbosticThe symbolic mode is described by the following grammar:
7747089Scael.Bd -literal -offset indent
7847089Scaelmode         ::= clause [, clause ...]
7947089Scaelclause       ::= [who ...] [action ...] last_action
8047089Scaelaction       ::= op [perm ...]
8147089Scaellast_action  ::= op [perm ...]
8247089Scaelwho          ::= a | u | g | o
8347089Scaelop           ::= + | \- | =
8447089Scaelperm         ::= r | s | t | w | X | x | u | g | o
8547089Scael.Ed
8643082Scael.Pp
8739829SbosticThe
8843082Scael.Ar who
8939829Sbosticsymbols ``u'', ``g'', and ``o'' specify the user, group, and other parts
9039829Sbosticof the mode bits, respectively.
9141117SbosticThe
9243082Scael.Ar who
9341117Sbosticsymbol ``a'' is equivalent to ``ugo''.
9443082Scael.Pp
9539829SbosticThe
9643082Scael.Ar perm
9739829Sbosticsymbols represent the portions of the mode bits as follows:
9847089Scael.Pp
9947089Scael.Bl -tag -width Ds -compact -offset indent
10047089Scael.It r
10139829SbosticThe read bits.
10247089Scael.It s
10339829SbosticThe set-user-ID-on-execution and set-group-ID-on-execution bits.
10447089Scael.It t
10541117SbosticThe sticky bit.
10647089Scael.It w
10739829SbosticThe write bits.
10847089Scael.It x
10941117SbosticThe execute/search bits.
11047089Scael.It X
11139829SbosticThe execute/search bits if the file is a directory or any of the
11241117Sbosticexecute/search bits are set in the original (unmodified) mode.
11341117SbosticOperations with the
11443082Scael.Ar perm
11541117Sbosticsymbol ``X'' are only meaningful in conjunction with the
11643082Scael.Ar op
11741117Sbosticsymbol ``+'', and it is ignored in all other cases.
11847089Scael.El
11943082Scael.Pp
12039829SbosticThe
12143082Scael.Ar op
12239829Sbosticsymbols represent the operation performed, as follows:
12347089Scael.Bl -tag -width 4n
12447089Scael.It +
12539829SbosticIf no value is supplied for
12643082Scael.Ar perm ,
12739829Sbosticthe ``+'' operation has no effect.
12839829SbosticIf no value is supplied for
12943082Scael.Ar who ,
13039829Sbosticeach permission bit specified in
13143082Scael.Ar perm ,
13241117Sbosticfor which the corresponding bit in the file mode creation mask
13341117Sbosticis clear, is set.
13441117SbosticOtherwise, the mode bits represented by the specified
13543082Scael.Ar who
13639829Sbosticand
13743082Scael.Ar perm
13841117Sbosticvalues are set.
13947089Scael.It \&\-
14039829SbosticIf no value is supplied for
14143082Scael.Ar perm ,
14247089Scaelthe ``\-'' operation has no effect.
14341117SbosticIf no value is supplied for
14443082Scael.Ar who ,
14541117Sbosticthe mode bits represented by
14643082Scael.Ar perm
14741117Sbosticare cleared for the owner, group and other permissions.
14841117SbosticOtherwise, the mode bits represented by the specified
14943082Scael.Ar who
15039829Sbosticand
15143082Scael.Ar perm
15241117Sbosticvalues are cleared.
15347089Scael.It =
15441117SbosticThe mode bits specified by the
15543082Scael.Ar who
15641117Sbosticvalue are cleared, or, if no who value is specified, the owner, group
15741117Sbosticand other mode bits are cleared.
15841117SbosticThen, if no value is supplied for
15943082Scael.Ar who ,
16041117Sbosticeach permission bit specified in
16143082Scael.Ar perm ,
16241117Sbosticfor which the corresponding bit in the file mode creation mask
16341117Sbosticis clear, is set.
16441117SbosticOtherwise, the mode bits represented by the specified
16543082Scael.Ar who
16639829Sbosticand
16743082Scael.Ar perm
16841117Sbosticvalues are set.
16947089Scael.El
17043082Scael.Pp
17141117SbosticEach
17243082Scael.Ar clause
17341117Sbosticspecifies one or more operations to be performed on the mode
17441117Sbosticbits, and each operation is applied to the mode bits in the
17541117Sbosticorder specified.
17643082Scael.Pp
17741117SbosticOperations upon the other permissions only (specified by the symbol
17841117Sbostic``o'' by itself), in combination with the
17943082Scael.Ar perm
18041117Sbosticsymbols ``s'' or ``t'', are ignored.
18143082Scael.Sh EXAMPLES
18247089Scael.Bl -tag -width "u=rwx,go=u-w" -compact
18347089Scael.It Li 644
18441117Sbosticmake a file readable by anyone and writable by the owner only.
18547089Scael.Pp
18647089Scael.It Li go-w
18739829Sbosticdeny write permission to group and others.
18847089Scael.Pp
18947089Scael.It Li =rw,+X
19041117Sbosticset the read and write permissions to the usual defaults, but
19141117Sbosticretain any execute permissions that are currently set.
19247089Scael.Pp
19347089Scael.It Li +X
19441117Sbosticmake a directory or file searchable/executable by everyone if it is
19541117Sbosticalready searchable/executable by anyone.
19647089Scael.Pp
19747089Scael.It Li 755
19847089Scael.It Li u=rwx,go=rx
19947089Scael.It Li u=rwx,go=u-w
20041117Sbosticmake a file readable/executable by everyone and writeable by the owner only.
20147089Scael.Pp
20247089Scael.It Li go=
20339829Sbosticclear all mode bits for group and others.
20447089Scael.Pp
20547089Scael.It Li g=u-w
20645902Sbosticset the group bits equal to the user bits, but clear the group write bit.
20747089Scael.El
20843082Scael.Sh BUGS
20939829SbosticThere's no
21043082Scael.Ar perm
21139829Sbosticoption for the naughty bits.
21243082Scael.Sh SEE ALSO
21343082Scael.Xr install 1 ,
21443082Scael.Xr chmod 2 ,
21543082Scael.Xr stat 2 ,
21643082Scael.Xr umask 2 ,
21745903Sbostic.Xr fts 3 ,
21843082Scael.Xr setmode 3 ,
21943082Scael.Xr chown 8
22043082Scael.Sh STANDARDS
22139829SbosticThe
22243082Scael.Nm chmod
22344952Scaelutility is expected to be POSIX 1003.2 compatible with the exception
22439829Sbosticof the
22543082Scael.Ar perm
22647089Scaelsymbols
22747089Scael.Dq t
22847089Scaeland
22947089Scael.Dq X
23047089Scaelwhich are not included in that standard.
231