Update to reflect recent changes to coreutils.texi.
[platform/upstream/coreutils.git] / man / chmod.x
1 [NAME]
2 chmod \- change file mode bits
3 [DESCRIPTION]
4 This manual page
5 documents the GNU version of
6 .BR chmod .
7 .B chmod
8 changes the file mode bits of each given file according to
9 .IR mode ,
10 which can be either a symbolic representation of changes to make, or
11 an octal number representing the bit pattern for the new mode bits.
12 .PP
13 The format of a symbolic mode is [\c
14 \fBugoa\fP.\|.\|.][[\fB+-=\fP][\fIperms\fP.\|.\|.].\|.\|.],
15 where
16 .I "perms"
17 is either zero or more letters from the set
18 \fBrwxXst\fP, or a single letter from the set \fBugo\fP.
19 Multiple symbolic
20 modes can be given, separated by commas.
21 .PP
22 A combination of the letters \fBugoa\fP controls which users' access
23 to the file will be changed: the user who owns it (\fBu\fP), other
24 users in the file's group (\fBg\fP), other users not in the file's
25 group (\fBo\fP), or all users (\fBa\fP).  If none of these are given,
26 the effect is as if \fBa\fP were
27 given, but bits that are set in the umask are not affected.
28 .PP
29 The operator \fB+\fP causes the selected file mode bits to be added to
30 the existing file mode bits of each file; \fB-\fP causes them to be
31 removed; and \fB=\fP causes them to be added and causes unmentioned
32 bits to be removed except that a directory's unmentioned set user and
33 group ID bits are not affected.
34 .PP
35 The letters \fBrwxXst\fP select file mode bits for the affected users:
36 read (\fBr\fP), write (\fBw\fP), execute (or search for directories)
37 (\fBx\fP), execute/search only if the file is a directory or already
38 has execute permission for some user (\fBX\fP), set user or group ID
39 on execution (\fBs\fP), restricted deletion flag or sticky bit
40 (\fBt\fP).  Instead of one or more of these letters, you can specify
41 exactly one of the letters \fBugo\fP: the permissions granted to the
42 user who owns the file (\fBu\fP), the permissions granted to other
43 users who are members of the file's group (\fBg\fP),
44 and the permissions granted to users that are in neither of the two preceding
45 categories (\fBo\fP).
46 .PP
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
49 assumed to be leading zeros, except that if the first digit is
50 omitted, a directory's set user and group ID bits are not affected.
51 The first digit selects the set user ID (4) and set group ID (2) and
52 restricted deletion or sticky (1) attributes.  The second digit
53 selects permissions for the user who owns the file: read (4), write (2),
54 and execute (1); the third selects permissions for other users in the
55 file's group, with the same values; and the fourth for other users not
56 in the file's group, with the same values.
57 .PP
58 .B chmod
59 never changes the permissions of symbolic links; the
60 .B chmod
61 system call cannot change their permissions.  This is not a problem
62 since the permissions of symbolic links are never used.
63 However, for each symbolic link listed on the command line,
64 .B chmod
65 changes the permissions of the pointed-to file.
66 In contrast,
67 .B chmod
68 ignores symbolic links encountered during recursive directory
69 traversals.
70 .SH "RESTRICTED DELETION FLAG OR STICKY BIT"
71 The restricted deletion flag or sticky bit is a single bit, whose
72 interpretation depends on the file type.  For directories, it prevents
73 unprivileged users from removing or renaming a file in the directory
74 unless they own the file or the directory; this is called the
75 .I "restricted deletion flag"
76 for the directory, and is commonly found on world-writable directories
77 like \fB/tmp\fP.  For regular files on some older systems, the bit
78 saves the program's text image on the swap device so it will load more
79 quickly when run; this is called the
80 .IR "sticky bit" .
81 .SH OPTIONS
82 [SEE ALSO]
83 chmod(2)