1CHMOD(1)                         User Commands                        CHMOD(1)
2
3
4

NAME

6       chmod - change file mode bits
7

SYNOPSIS

9       chmod [OPTION]... MODE[,MODE]... FILE...
10       chmod [OPTION]... OCTAL-MODE FILE...
11       chmod [OPTION]... --reference=RFILE FILE...
12

DESCRIPTION

14       This manual page documents the GNU version of chmod.  chmod changes the
15       file mode bits of each given file  according  to  mode,  which  can  be
16       either a symbolic representation of changes to make, or an octal number
17       representing the bit pattern for the new mode bits.
18
19       The format of a symbolic mode is  [ugoa...][[+-=][perms...]...],  where
20       perms  is  either zero or more letters from the set rwxXst, or a single
21       letter from the set ugo.  Multiple symbolic modes can be  given,  sepa‐
22       rated by commas.
23
24       A  combination  of the letters ugoa controls which users' access to the
25       file will be changed: the user who owns it  (u),  other  users  in  the
26       file's group (g), other users not in the file's group (o), or all users
27       (a).  If none of these are given, the effect is as if a were given, but
28       bits that are set in the umask are not affected.
29
30       The  operator  +  causes the selected file mode bits to be added to the
31       existing file mode bits of each file; - causes them to be removed;  and
32       =  causes  them  to  be added and causes unmentioned bits to be removed
33       except that a directory's unmentioned set user and group  ID  bits  are
34       not affected.
35
36       The  letters  rwxXst select file mode bits for the affected users: read
37       (r), write (w), execute (or search for directories) (x), execute/search
38       only  if  the file is a directory or already has execute permission for
39       some user (X), set user or group ID on execution (s), restricted  dele‐
40       tion  flag or sticky bit (t).  Instead of one or more of these letters,
41       you can specify exactly one of the letters ugo: the permissions granted
42       to  the  user  who  owns the file (u), the permissions granted to other
43       users who are members of the file's  group  (g),  and  the  permissions
44       granted  to  users  that are in neither of the two preceding categories
45       (o).
46
47       A numeric mode is from one to  four  octal  digits  (0-7),  derived  by
48       adding up the bits with values 4, 2, and 1.  Omitted digits are assumed
49       to be leading zeros.  The first digit selects the set user ID  (4)  and
50       set group ID (2) and restricted deletion or sticky (1) attributes.  The
51       second digit selects permissions for the user who owns the  file:  read
52       (4),  write  (2),  and  execute  (1); the third selects permissions for
53       other users in the file's group, with the same values; and  the  fourth
54       for other users not in the file's group, with the same values.
55
56       chmod never changes the permissions of symbolic links; the chmod system
57       call cannot change their permissions.  This is not a problem since  the
58       permissions  of  symbolic links are never used.  However, for each sym‐
59       bolic link listed on the command line, chmod changes the permissions of
60       the pointed-to file.  In contrast, chmod ignores symbolic links encoun‐
61       tered during recursive directory traversals.
62

SETUID AND SETGID BITS

64       chmod clears the set-group-ID bit of a regular file if the file's group
65       ID  does  not  match the user's effective group ID or one of the user's
66       supplementary group IDs, unless the user  has  appropriate  privileges.
67       Additional restrictions may cause the set-user-ID and set-group-ID bits
68       of MODE or RFILE to be ignored.  This behavior depends  on  the  policy
69       and  functionality of the underlying chmod system call.  When in doubt,
70       check the underlying system behavior.
71
72       chmod preserves a directory's set-user-ID and set-group-ID bits  unless
73       you  explicitly  specify otherwise.  You can set or clear the bits with
74       symbolic modes like u+s and g-s, and you can set (but  not  clear)  the
75       bits with a numeric mode.
76

RESTRICTED DELETION FLAG OR STICKY BIT

78       The  restricted  deletion  flag  or  sticky  bit is a single bit, whose
79       interpretation depends on the file type.  For directories, it  prevents
80       unprivileged  users  from  removing or renaming a file in the directory
81       unless they  own  the  file  or  the  directory;  this  is  called  the
82       restricted  deletion  flag  for the directory, and is commonly found on
83       world-writable directories like /tmp.  For regular files on some  older
84       systems,  the  bit saves the program's text image on the swap device so
85       it will load more quickly when run; this is called the sticky bit.
86

OPTIONS

88       Change the mode of each FILE to MODE.   With  --reference,  change  the
89       mode of each FILE to that of RFILE.
90
91       -c, --changes
92              like verbose but report only when a change is made
93
94       -f, --silent, --quiet
95              suppress most error messages
96
97       -v, --verbose
98              output a diagnostic for every file processed
99
100       --no-preserve-root
101              do not treat '/' specially (the default)
102
103       --preserve-root
104              fail to operate recursively on '/'
105
106       --reference=RFILE
107              use RFILE's mode instead of MODE values
108
109       -R, --recursive
110              change files and directories recursively
111
112       --help display this help and exit
113
114       --version
115              output version information and exit
116
117       Each           MODE           is          of          the          form
118       '[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+'.
119
120       GNU  coreutils  online  help:  <http://www.gnu.org/software/coreutils/>
121       Report chmod translation bugs to <http://translationproject.org/team/>
122

AUTHOR

124       Written by David MacKenzie and Jim Meyering.
125
127       Copyright  ©  2013  Free Software Foundation, Inc.  License GPLv3+: GNU
128       GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
129       This is free software: you are free  to  change  and  redistribute  it.
130       There is NO WARRANTY, to the extent permitted by law.
131

SEE ALSO

133       chmod(2)
134
135       The full documentation for chmod is maintained as a Texinfo manual.  If
136       the info and chmod programs are properly installed at  your  site,  the
137       command
138
139              info coreutils 'chmod invocation'
140
141       should give you access to the complete manual.
142
143
144
145GNU coreutils 8.22               October 2018                         CHMOD(1)
Impressum