1CHMOD(1) User Commands CHMOD(1)
2
3
4
6 chmod - change file mode bits
7
9 chmod [OPTION]... MODE[,MODE]... FILE...
10 chmod [OPTION]... OCTAL-MODE FILE...
11 chmod [OPTION]... --reference=RFILE FILE...
12
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, except that if the first digit is omitted, a
50 directory's set user and group ID bits are not affected. The first
51 digit selects the set user ID (4) and set group ID (2) and restricted
52 deletion or sticky (1) attributes. The second digit selects permis‐
53 sions for the user who owns the file: read (4), write (2), and execute
54 (1); the third selects permissions for other users in the file's group,
55 with the same values; and the fourth for other users not in the file's
56 group, with the same values.
57
58 chmod never changes the permissions of symbolic links; the chmod system
59 call cannot change their permissions. This is not a problem since the
60 permissions of symbolic links are never used. However, for each sym‐
61 bolic link listed on the command line, chmod changes the permissions of
62 the pointed-to file. In contrast, chmod ignores symbolic links encoun‐
63 tered during recursive directory traversals.
64
66 The restricted deletion flag or sticky bit is a single bit, whose
67 interpretation depends on the file type. For directories, it prevents
68 unprivileged users from removing or renaming a file in the directory
69 unless they own the file or the directory; this is called the
70 restricted deletion flag for the directory, and is commonly found on
71 world-writable directories like /tmp. For regular files on some older
72 systems, the bit saves the program's text image on the swap device so
73 it will load more quickly when run; this is called the sticky bit.
74
76 Change the mode of each FILE to MODE.
77
78 -c, --changes
79 like verbose but report only when a change is made
80
81 --no-preserve-root
82 do not treat `/' specially (the default)
83
84 --preserve-root
85 fail to operate recursively on `/'
86
87 -f, --silent, --quiet
88 suppress most error messages
89
90 -v, --verbose
91 output a diagnostic for every file processed
92
93 --reference=RFILE
94 use RFILE's mode instead of MODE values
95
96 -R, --recursive
97 change files and directories recursively
98
99 --help display this help and exit
100
101 --version
102 output version information and exit
103
104 Each MODE is of the form `[ugoa]*([-+=]([rwxXst]*|[ugo]))+'.
105
107 Written by David MacKenzie and Jim Meyering.
108
110 Report bugs to <bug-coreutils@gnu.org>.
111
113 Copyright © 2007 Free Software Foundation, Inc.
114 This is free software. You may redistribute copies of it under the
115 terms of the GNU General Public License
116 <http://www.gnu.org/licenses/gpl.html>. There is NO WARRANTY, to the
117 extent permitted by law.
118
120 chmod(2)
121
122 The full documentation for chmod is maintained as a Texinfo manual. If
123 the info and chmod programs are properly installed at your site, the
124 command
125
126 info chmod
127
128 should give you access to the complete manual.
129
130
131
132GNU coreutils 6.9 March 2008 CHMOD(1)