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.
89
90       -c, --changes
91              like verbose but report only when a change is made
92
93       --no-preserve-root
94              do not treat `/' specially (the default)
95
96       --preserve-root
97              fail to operate recursively on `/'
98
99       -f, --silent, --quiet
100              suppress most error messages
101
102       -v, --verbose
103              output a diagnostic for every file processed
104
105       --reference=RFILE
106              use RFILE's mode instead of MODE values
107
108       -R, --recursive
109              change files and directories recursively
110
111       --help display this help and exit
112
113       --version
114              output version information and exit
115
116       Each MODE is of the form `[ugoa]*([-+=]([rwxXst]*|[ugo]))+'.
117

AUTHOR

119       Written by David MacKenzie and Jim Meyering.
120

REPORTING BUGS

122       Report chmod bugs to bug-coreutils@gnu.org
123       GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
124       General help using GNU software: <http://www.gnu.org/gethelp/>
125       Report chmod translation bugs to <http://translationproject.org/team/>
126
128       Copyright © 2010 Free Software Foundation, Inc.   License  GPLv3+:  GNU
129       GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
130       This  is  free  software:  you  are free to change and redistribute it.
131       There is NO WARRANTY, to the extent permitted by law.
132

SEE ALSO

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