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  ei‐
16       ther  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,
28       but 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 ex‐
33       cept that a directory's unmentioned set user and group ID bits are  not
34       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       For directories chmod preserves set-user-ID and set-group-ID  bits  un‐
73       less  you  explicitly specify otherwise.  You can set or clear the bits
74       with symbolic modes like u+s and g-s.  To clear these bits for directo‐
75       ries  with  a  numeric  mode  requires  an additional leading zero like
76       00755, leading minus like -6000, or leading equals like =755.
77

RESTRICTED DELETION FLAG OR STICKY BIT

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

OPTIONS

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

AUTHOR

123       Written by David MacKenzie and Jim Meyering.
124

REPORTING BUGS

126       GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
127       Report any translation bugs to <https://translationproject.org/team/>
128
130       Copyright © 2023 Free Software Foundation, Inc.   License  GPLv3+:  GNU
131       GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
132       This  is  free  software:  you  are free to change and redistribute it.
133       There is NO WARRANTY, to the extent permitted by law.
134

SEE ALSO

136       chmod(2)
137
138       Full documentation <https://www.gnu.org/software/coreutils/chmod>
139       or available locally via: info '(coreutils) chmod invocation'
140
141
142
143GNU coreutils 9.3               September 2023                        CHMOD(1)
Impressum