1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" Modified by Michael Haardt <michael@moria.de>
26 .\" Modified 1993-07-21 by Rik Faith <faith@cs.unc.edu>
27 .\" Modified 1997-01-12 by Michael Haardt
28 .\" <michael@cantor.informatik.rwth-aachen.de>: NFS details
29 .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
31 .\" Japanese Version Copyright (c) 1996 Yosiaki Yanagihara
32 .\" all rights reserved.
33 .\" Translated 1996-06-24, Yosiaki Yanagihara <yosiaki@bsd2.kbnes.nec.co.jp>
34 .\" Modified 1998-05-11, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
35 .\" Updated & Modified 2001-06-25, Yuichi SATO <ysato@h4.dion.ne.jp>
36 .\" Updated & Modified 2004-12-29, Yuichi SATO <ysato444@yahoo.co.jp>
37 .\" Updated 2008-08-09, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.05
39 .TH CHMOD 2 2010-09-26 "Linux" "Linux Programmer's Manual"
42 .\"O chmod, fchmod \- change permissions of a file
43 chmod, fchmod \- ファイルのモードを変更する
46 .B #include <sys/stat.h>
48 .BI "int chmod(const char *" path ", mode_t " mode );
50 .BI "int fchmod(int " fd ", mode_t " mode );
53 .\"O Feature Test Macro Requirements for glibc (see
54 .\"O .BR feature_test_macros (7)):
56 .RB ( feature_test_macros (7)
65 _XOPEN_SOURCE\ >=\ 500 ||
66 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
68 .\"O || /* Since glibc 2.12: */ _POSIX_C_SOURCE\ >=\ 200809L
69 || /* glibc 2.12 以降: */ _POSIX_C_SOURCE\ >=\ 200809L
74 .\"O These system calls change the permissions of a file.
75 .\"O They differ only in how the file is specified:
76 これらのシステムコールはファイルのアクセス許可 (permission) を変更する。
77 システムコール間の違いは、ファイルの指定の仕方だけである。
80 .\"O changes the permissions of the file specified whose pathname is given in
82 .\"O which is dereferenced if it is a symbolic link.
86 で指定されたパス名を持つファイルの許可を変更する。
88 がシンボリック・リンクの場合は、リンクの展開が行われる。
91 .\"O changes the permissions of the file referred to by the open file descriptor
98 .\"O The new file permissions are specified in
100 .\"O which is a bit mask created by ORing together zero or
101 .\"O more of the following:
106 は、以下に示す値の 0 個以上の OR (論理和) をとって作成される
109 .BR S_ISUID " (04000)"
110 .\"O set-user-ID (set process effective user ID on
114 時にプロセスの実効ユーザ ID にセットされる)
116 .BR S_ISGID " (02000)"
117 .\"O set-group-ID (set process effective group ID on
119 .\"O mandatory locking, as described in
121 .\"O take a new file's group from parent directory, as described in
128 実行時にプロセスの実効グループ ID にセットされる、
129 強制ロック (mandatory locking) を行う
132 新しいファイルのグループとして親ディレクトリと同じものを使う
138 .BR S_ISVTX " (01000)"
139 .\"O sticky bit (restricted deletion flag, as described in
141 スティッキー・ビット (sticky bit) (削除制限フラグ、
145 .BR S_IRUSR " (00400)"
149 .BR S_IWUSR " (00200)"
153 .BR S_IXUSR " (00100)"
154 .\"O execute/search by owner ("search" applies for directories,
155 .\"O and means that entries within the directory can be accessed)
156 所有者による実行 (execute) / 検索 (search)
157 (「検索」はディレクトリに対して適用されるもので、
158 そのディレクトリ内のエントリーへアクセスできるかを意味する)
160 .BR S_IRGRP " (00040)"
164 .BR S_IWGRP " (00020)"
168 .BR S_IXGRP " (00010)"
169 .\"O execute/search by group
172 .BR S_IROTH " (00004)"
176 .BR S_IWOTH " (00002)"
180 .BR S_IXOTH " (00001)"
181 .\"O execute/search by others
184 .\"O The effective UID of the calling process must match the owner of the file,
185 .\"O or the process must be privileged (Linux: it must have the
188 呼び出したプロセスの実効 (effective) UID がファイルの所有者と一致するか、
192 ケーパビリティ (capability) を持たなければならない)。
194 .\"O If the calling process is not privileged (Linux: does not have the
196 .\"O capability), and the group of the file does not match
197 .\"O the effective group ID of the process or one of its
198 .\"O supplementary group IDs, the
200 .\"O bit will be turned off,
201 .\"O but this will not cause an error to be returned.
202 呼び出したプロセスに特権がなく (Linux では
204 ケーパビリティがなく)、かつファイルのグループ ID が
205 プロセスの実効グループ ID または補助的なグループ ID にマッチしない場合、
207 ビットはオフにされるが、これによってエラーが返されることはない。
209 .\"O As a security measure, depending on the file system,
210 .\"O the set-user-ID and set-group-ID execution bits
211 .\"O may be turned off if a file is written.
213 ファイル・システムによっては、ファイルの書き込みを行う時に
214 セット・ユーザー ID とセット・グループ ID ビットと実行ビットが
216 .\"O (On Linux this occurs if the writing process does not have the
221 ケーパビリティを持っていない場合に、これが起こる。)
222 .\"O On some file systems, only the superuser can set the sticky bit,
223 .\"O which may have a special meaning.
224 .\"O For the sticky bit, and for set-user-ID and set-group-ID bits on
225 .\"O directories, see
227 ファイル・システムの中には、スーパー・ユーザーだけが
228 特別の意味を持つスティッキー・ビットを設定できるものがある。
229 スティッキー・ビットとディレクトリに対する
230 セット・ユーザー (グループ)・ID ビットについては、
234 .\"O On NFS file systems, restricting the permissions will immediately influence
235 .\"O already open files, because the access control is done on the server, but
236 .\"O open files are maintained by the client.
237 .\"O Widening the permissions may be
238 .\"O delayed for other clients if attribute caching is enabled on them.
239 NFS ファイルシステム上では、パーミッションを制限すると、
240 既にオープンされているファイルに対してすぐに影響が及ぶ。
241 これはアクセス制御がサーバー上で行われているが、
242 オープンされているファイルはクライアント側で管理されているためである。
243 クライアント側でファイル属性のキャッシュが有効になっている場合に、
245 他のクライアントに情報が伝わるのが遅れるかもしれない。
246 .\"O .SH "RETURN VALUE"
248 .\"O On success, zero is returned.
249 .\"O On error, \-1 is returned, and
251 .\"O is set appropriately.
252 成功すると、0 を返す。失敗すると、\-1を返し、
257 .\"O Depending on the file system, other errors can be returned.
258 .\"O The more general errors for
260 .\"O are listed below:
261 ファイル・システムによっては他のエラーを返す場合がある。
266 .\"O Search permission is denied on a component of the path prefix.
268 .\"O .BR path_resolution (7).)
270 .RB ( path_resolution (7)
275 .\"O points outside your accessible address space.
277 が割り当てられたアドレス空間外を指している。
280 .\"O An I/O error occurred.
284 .\"O Too many symbolic links were encountered in resolving
287 を解決する際に遭遇したシンボリック・リンクが多過ぎる。
296 .\"O The file does not exist.
300 .\"O Insufficient kernel memory was available.
304 .\"O A component of the path prefix is not a directory.
308 .\"O The effective UID does not match the owner of the file,
309 .\"O and the process is not privileged (Linux: it does not have the
312 実効 UID がファイルの所有者と一致せず、プロセスに特権がない
318 .\"O The named file resides on a read-only file system.
319 ファイルが読み込み専用 (read only) のファイル・システム上にある。
321 .\"O The general errors for
323 .\"O are listed below:
328 .\"O The file descriptor
346 .\"O .SH "CONFORMING TO"
348 4.4BSD, SVr4, POSIX.1-2001.
356 .BR path_resolution (7)