Commit | Line | Data |
---|---|---|
2da69ef2 | 1 | .\" @(#)chmod.1 6.3 (Berkeley) %G% |
aed64a6e | 2 | .\" |
87a10ef1 | 3 | .TH CHMOD 1 "" |
aed64a6e KM |
4 | .AT 3 |
5 | .SH NAME | |
6 | chmod \- change mode | |
7 | .SH SYNOPSIS | |
87a10ef1 | 8 | \fBchmod\fP [ |
16b7e896 | 9 | .B \-Rf |
87a10ef1 | 10 | ] mode file ... |
aed64a6e | 11 | .SH DESCRIPTION |
9dfaf149 KM |
12 | The mode of each named file is changed according to \fImode\fP, |
13 | which may be absolute or symbolic. An absolute \fImode\fP | |
14 | is an octal number constructed from the OR of the following modes: | |
aed64a6e KM |
15 | .TP 10 |
16 | 4000 | |
17 | set user ID on execution | |
18 | .br | |
aed64a6e KM |
19 | .ns |
20 | .TP 10 | |
21 | 2000 | |
22 | set group ID on execution | |
23 | .br | |
aed64a6e KM |
24 | .ns |
25 | .TP 10 | |
26 | 1000 | |
27 | sticky bit, see | |
28 | .IR chmod (2) | |
29 | .br | |
aed64a6e KM |
30 | .ns |
31 | .TP 10 | |
32 | 0400 | |
33 | read by owner | |
34 | .br | |
aed64a6e KM |
35 | .ns |
36 | .TP 10 | |
37 | 0200 | |
38 | write by owner | |
39 | .br | |
aed64a6e KM |
40 | .ns |
41 | .TP 10 | |
42 | 0100 | |
43 | execute (search in directory) by owner | |
44 | .br | |
aed64a6e KM |
45 | .ns |
46 | .TP 10 | |
47 | 0070 | |
48 | read, write, execute (search) by group | |
49 | .br | |
aed64a6e KM |
50 | .ns |
51 | .TP 10 | |
52 | 0007 | |
53 | read, write, execute (search) by others | |
9dfaf149 KM |
54 | .LP |
55 | A symbolic \fImode\fP has the form: | |
aed64a6e KM |
56 | .IP |
57 | .RI [ who ] | |
9dfaf149 | 58 | \fIop permission\fP |
aed64a6e | 59 | .RI [ "op permission" "] ..." |
9dfaf149 KM |
60 | .LP |
61 | The \fIwho\fP part is a combination of the letters \fBu\fP | |
62 | (for user's permissions), \fBg\fP (group) and \fBo\fP (other). | |
63 | The letter \fBa\fP stands for all, or \fBugo.\fP | |
64 | If \fIwho\fP is omitted, the default is \fIa\fP | |
65 | but the setting of the file creation mask (see umask(2)) is taken into account. | |
66 | .LP | |
67 | \fIOp\fP can be \fB+\fP to add \fIpermission\fP to the file's mode, | |
68 | \fB\-\fP to take away \fIpermission\fP and \fB=\fP to assign | |
69 | \fIpermission\fP absolutely (all other bits will be reset). | |
70 | .LP | |
71 | \fIPermission\fP is any combination of the letters \fBr\fP (read), | |
87a10ef1 KM |
72 | \fBw\fP (write), \fBx\fP (execute), |
73 | \fBX\fP (set execute only if file is a directory | |
74 | or some other execute bit is set), | |
75 | \fBs\fP (set owner or group id) | |
76 | and \fBt\fP (save text \- sticky). | |
77 | Letters \fBu\fP, \fBg\fP, or \fBo\fP indicate that \fIpermission\fP | |
78 | is to be taken from the current mode. | |
79 | Omitting \fIpermission\fP | |
9dfaf149 | 80 | is only useful with \fB=\fP to take away all permissions. |
87a10ef1 KM |
81 | .PP |
82 | When the | |
83 | .B \-R | |
84 | option is given, | |
85 | .I chmod | |
86 | recursively descends its directory arguments | |
87 | setting the mode for each file as described above. | |
2da69ef2 KM |
88 | When symbolic links are encountered, their mode is not changed |
89 | and they are not traversed. | |
16b7e896 SL |
90 | .PP |
91 | If the | |
92 | .B \-f | |
93 | option is given, | |
94 | .I chmod | |
95 | will not complain if it fails to change the mode | |
96 | on a file. | |
9dfaf149 KM |
97 | .SH EXAMPLES |
98 | .LP | |
aed64a6e | 99 | The first example denies write permission to others, |
87a10ef1 | 100 | the second makes a file executable by all if it is executable by anyone: |
aed64a6e KM |
101 | .IP |
102 | chmod o\-w file | |
103 | .br | |
87a10ef1 | 104 | chmod +X file |
9dfaf149 | 105 | .LP |
aed64a6e | 106 | Multiple symbolic modes separated by commas may be given. |
9dfaf149 KM |
107 | Operations are performed in the order specified. The letter |
108 | \fBs\fP is only useful with \fBu\fP or \fBg.\fP | |
109 | .LP | |
aed64a6e KM |
110 | Only the owner of a file (or the super-user) may change its mode. |
111 | .SH "SEE ALSO" | |
9dfaf149 | 112 | ls(1), chmod(2), stat(2), umask(2), chown(8) |