Usage: chmod [OPTION]... MODE[,MODE]... FILE...
or: chmod [OPTION]... OCTAL-MODE FILE...
or: chmod [OPTION]... --reference=RFILE FILE...
Change the mode of each FILE to MODE.
-c, --changes like verbose but report only when a change is made
--no-preserve-root do not treat `/' specially (the default)
--preserve-root fail to operate recursively on `/'
-f, --silent, --quiet suppress most error messages
-v, --verbose output a diagnostic for every file processed
--reference=RFILE use RFILE's mode instead of MODE values
-R, --recursive change files and directories recursively
--help この使い方を表示して終了
--version バージョン情報を表示して終了
Each MODE is of the form `[ugoa]*([-+=]([rwxXst]*|[ugo]))+'.
Report chmod bugs to bug-coreutils@gnu.org
GNU coreutils home page:
Usage: chmod [OPTION]... MODE[,MODE]... FILE...
or: chmod [OPTION]... OCTAL-MODE FILE...
or: chmod [OPTION]... --reference=RFILE FILE...
Change the mode of each FILE to MODE.
-c, --changes like verbose but report only when a change is made
--no-preserve-root do not treat `/' specially (the default)
--preserve-root fail to operate recursively on `/'
-f, --silent, --quiet suppress most error messages
-v, --verbose output a diagnostic for every file processed
--reference=RFILE use RFILE's mode instead of MODE values
-R, --recursive change files and directories recursively
--help display this help and exit
--version output version information and exit
Each MODE is of the form `[ugoa]*([-+=]([rwxXst]*|[ugo]))+'.
Report chmod bugs to bug-coreutils@gnu.org
GNU coreutils home page:
CHMOD(1) CHMOD(1) 名前 chmod - ファイルのアクセス権を変更する 書式 chmod [options] mode file... POSIX オプション: [-R] GNU オプション (簡略形式): [-cfvR] [--reference=file] [--help] [--ver- sion] [--] 説明 chmod コマンドは指定したそれぞれの file のアクセス権を mode により変 更 す る。変更方法をシンボルで表現するか、もしくは変更後のアクセス権を表す ビットパターンを 8 進数で表現したもののいずれかを使うことができる。 シンボルモードでアクセス権を変更する場合の引数の書式は ‘[ugoa...][[+-=][rwxXstugo...]...][,...]’ である。 シンボルモードで引数にアクセス権の変更を複数指定する場合にはコンマで 区 切る。シンボルモードでアクセス権を変更するそれぞれの表現は 0 個もしくは 複数の文字 ‘ugoa’ で始まる; これらがファイルに対するどのユーザーのア ク セ ス権を変更するかを決める: ファイルの所有者 (u)、ファイルと同じグルー プに属しているが所有者ではない (訳注: 以後グループと表記) (g)、所有者で も なく、そのファイルと同じグループにも属していない (訳注: 以後その他と 表記) (o)、もしくは全ユーザー (a) を表している。つまり ‘a’ は ‘ugo’ と 同 じである。もしこれらのいずれも指定されない場合、‘a’ が指定されたのと 同じ結果となるが、umask に設定されたビット位置は変化しない。 ‘+’ 演算子は各々のファイルの現状のアクセス権に、選択したアクセス権を 加 える; ‘-’ は削除する; そして ‘=’ は指定したアクセス権だけがそのファイル のアクセス権となる。 文字 ‘rwxXstugo’ は影響を与えるユーザーに対する新しいアクセス権を選択す る: 読取り (r)、書き込み (w)、実行 (またはディレクトリに対するアクセス) (x)、ファイルがディレクトリかもしくはあるユーザーに対してすでに実行アク セ ス権が設定されている場合のみ実行 (X)、実行時にユーザーもしくはグルー プ IDを設定する (s)、sticky bit (t)、そのファイルの所有者での現在のアク セ ス権は (u)、そのファイルのグループでの現在のアクセス権は (g)、そのフ ァイルのその他のユーザーでの現在のアクセス権は (o) で表される。 (従って 、‘chmod g-s file’ は set-group-ID (sgid) ビットを削除する。 ‘chmod ug+s file’ は suid そして sgid ビットの両方を設定するが 、 ‘chmod o+s file’ は何もしない。) POSIX では ‘sticky bit’ について記述していない。その名前は本来の意味か ら来ている: プログラムコードをスワップ上に維持する。最近は、ディレク ト リ に設定されている場合、ファイルの所有者とディレクトリの所有者だけがそ のディレクトリからファイルを削除できることを意味する。 (全ユーザーが 書 き 込みアクセス権を持つ /tmp のようなディレクトリでこれはごく普通に使わ れている。) chmod コマンドがシンボリックリンクのアクセス権を変更することは決して な い。なぜなら、 chmod システムコールはシンボリックリンクのアクセス権を変 更することができないからである。シンボリックリンクのアクセス権は決し て 使われることがないため、このことは問題ではない。しかし、 chmod コマンド は引数にシンボリックリンクが指定された場合、各々についてそれが指して い るファイルのアクセス権を変更する。それに対して、 chmod コマンドは再帰的 にディレクトリを移動しながら処理している時に見つけたシンボリックリン ク は無視する。 POSIX オプション -R ディレクトリやそこに含まれるもののアクセス権を再帰的に変更する。 GNU オプション -c, --changes 実際にアクセス権の変更があった file それぞれについての動作を詳細 に表示する。 -f, --silent, --quiet アクセス権を変更できなかったファイルについてのエラーメッセージを 出力しない。 -v, --verbose 全ての file について変更した、もしくはしなかったという動作を詳細 に表示する。 -R, --recursive ディレクトリやそこに含まれるもののアクセス権を再帰的に変更する。 --reference=file 明示的に mode を指示する代わりに、参照用に指定した file のグルー プを使う。 GNU 標準オプション --help 標準出力に使用方法のメッセージを出力して正常終了する。 --version 標準出力にバージョン情報を出力して正常終了する。 -- オプションリストを終了する。 数値モード フ ァイルのアクセス権は内部的に 16 ビットの整数で保持されている。シンボ ルでアクセス権を指定する代わりに、これから変更するアクセス権の内部表 現 に対応した 8 進数 (基数 8) を使って指定することができる。この数値は常に 8 進数として扱われる; C 言語のように数値の先頭に 0 を付加する必要はない 。 mode に 0055 と指定するのと 55 と指定するのは同じである。数値モード による指定は、シンボルモードで指定するより大抵の場合短くすむが、アク セ ス 権を絶対値で指定する。 mode の各数字により、以下で示すようなアクセス 権のグループを選択する。左側の省略された数値は 0 として扱われる。アクセ ス権を組み合わせるには、各数字の OR をとるか各数字を合計すればよい。 特別なアクセス権 1000 プログラムコードをスワップに維持 2000 実行時にグループ ID を設定 4000 実行時にユーザー ID を設定 同じ UID のユーザー (u+) 100 実行 200 書き込み 400 読み込み 同じグループ (g+) 10 実行 20 書き込み 40 読み込み その他のユーザー (o+) 1 実行 2 書き込み 4 読み込み 環境変数 変数 LANG, LC_ALL, LC_CTYPE, LC_MESSAGES が通常の意味を持つ。 準拠 POSIX 1003.2 では -R オプションのみが必須である。その他のオプションを使 用すると互換性がないかもしれない。この標準では ’t’ の許可ビットについて 説明していない。この標準では chmod が suid や sgid ビットのクリアもしく は設定の拒絶での一貫性を維持するべきかどうかについてをとり決めていな い 。 たとえば、すべての実行ビットがクリアされる場合に chmod が ‘s’ ビット をどうするかまったくとり決めていない。 非標準モード ここまでのところでディレクトリに対する ‘t’ ビットの使い方を説明した。い ろ いろなシステムでは、他の意味のないモードビットの組合せに特別な意味を 与えている。特に、Linux は System V 系 (System V Interface Definition (SVID) Version 3 を参照) に倣って、グループ実行許可を持たないファイルの sgid ビットに、そのファイルが強制ロック (mandatory locking) の対象で あ る こ と を 示 さ せ て い る。詳細については /usr/src/linux/Documenta- tion/mandatory.txt ファイルを参照。 注意 このページでは fileutils-4.1 パッケージでの chmod コマンドについて説 明 し ている。その他のバージョンでは少し違いがあるかもしれない。修正や追加 は aeb@cwi.nl, aw@mail1.bet1.puv.fi, ragnar@ragnar-hojland.com 宛てにメ ー ルで連絡してほしい。プログラムのバグについては bug-fileutils@gnu.org へ報告してほしい。 GNU fileutils 4.1 18 June 2002 CHMOD(1)
CHMOD(1) User Commands CHMOD(1)
NAME
chmod - change file mode bits
SYNOPSIS
chmod [OPTION]... MODE[,MODE]... FILE...
chmod [OPTION]... OCTAL-MODE FILE...
chmod [OPTION]... --reference=RFILE FILE...
DESCRIPTION
This manual page documents the GNU version of chmod. chmod changes the
file mode bits of each given file according to mode, which can be
either a symbolic representation of changes to make, or an octal number
representing the bit pattern for the new mode bits.
The format of a symbolic mode is [ugoa...][[+-=][perms...]...], where
perms is either zero or more letters from the set rwxXst, or a single
letter from the set ugo. Multiple symbolic modes can be given, sepa-
rated by commas.
A combination of the letters ugoa controls which users’ access to the
file will be changed: the user who owns it (u), other users in the
file’s group (g), other users not in the file’s group (o), or all users
(a). If none of these are given, the effect is as if a were given, but
bits that are set in the umask are not affected.
The operator + causes the selected file mode bits to be added to the
existing file mode bits of each file; - causes them to be removed; and
= causes them to be added and causes unmentioned bits to be removed
except that a directory’s unmentioned set user and group ID bits are
not affected.
The letters rwxXst select file mode bits for the affected users: read
(r), write (w), execute (or search for directories) (x), execute/search
only if the file is a directory or already has execute permission for
some user (X), set user or group ID on execution (s), restricted dele-
tion flag or sticky bit (t). Instead of one or more of these letters,
you can specify exactly one of the letters ugo: the permissions granted
to the user who owns the file (u), the permissions granted to other
users who are members of the file’s group (g), and the permissions
granted to users that are in neither of the two preceding categories
(o).
A numeric mode is from one to four octal digits (0-7), derived by
adding up the bits with values 4, 2, and 1. Omitted digits are assumed
to be leading zeros. The first digit selects the set user ID (4) and
set group ID (2) and restricted deletion or sticky (1) attributes. The
second digit selects permissions for the user who owns the file: read
(4), write (2), and execute (1); the third selects permissions for
other users in the file’s group, with the same values; and the fourth
for other users not in the file’s group, with the same values.
chmod never changes the permissions of symbolic links; the chmod system
call cannot change their permissions. This is not a problem since the
permissions of symbolic links are never used. However, for each sym-
bolic link listed on the command line, chmod changes the permissions of
the pointed-to file. In contrast, chmod ignores symbolic links encoun-
tered during recursive directory traversals.
SETUID AND SETGID BITS
chmod clears the set-group-ID bit of a regular file if the file’s group
ID does not match the user’s effective group ID or one of the user’s
supplementary group IDs, unless the user has appropriate privileges.
Additional restrictions may cause the set-user-ID and set-group-ID bits
of MODE or RFILE to be ignored. This behavior depends on the policy
and functionality of the underlying chmod system call. When in doubt,
check the underlying system behavior.
chmod preserves a directory’s set-user-ID and set-group-ID bits unless
you explicitly specify otherwise. You can set or clear the bits with
symbolic modes like u+s and g-s, and you can set (but not clear) the
bits with a numeric mode.
RESTRICTED DELETION FLAG OR STICKY BIT
The restricted deletion flag or sticky bit is a single bit, whose
interpretation depends on the file type. For directories, it prevents
unprivileged users from removing or renaming a file in the directory
unless they own the file or the directory; this is called the
restricted deletion flag for the directory, and is commonly found on
world-writable directories like /tmp. For regular files on some older
systems, the bit saves the program’s text image on the swap device so
it will load more quickly when run; this is called the sticky bit.
OPTIONS
Change the mode of each FILE to MODE.
-c, --changes
like verbose but report only when a change is made
--no-preserve-root
do not treat ‘/’ specially (the default)
--preserve-root
fail to operate recursively on ‘/’
-f, --silent, --quiet
suppress most error messages
-v, --verbose
output a diagnostic for every file processed
--reference=RFILE
use RFILE’s mode instead of MODE values
-R, --recursive
change files and directories recursively
--help display this help and exit
--version
output version information and exit
Each MODE is of the form ‘[ugoa]*([-+=]([rwxXst]*|[ugo]))+’.
AUTHOR
Written by David MacKenzie and Jim Meyering.
REPORTING BUGS
Report chmod bugs to bug-coreutils@gnu.org
GNU coreutils home page:
Copyright(C) linux-cmd.com All Rights Reserved. Author Takayuki Yukawa