chmod
linuxchmodは、ファイルやディレクトリのパーミッション(アクセス権)を変更する。 パーミッション変更する場合は、「記号(ugoa / +-= / rwx)」及び「数字(755…etc)」で指定を行う。
[user@centos7 ~]$ chmod 記号(ugoa / +-= / rwx) or 数字(755...etc) ファイル名
option
| -c | パーミッションが変更されたファイルのみ詳細を表示 |
|---|---|
| -f | パーミッションが変更できなかった場合でも、エラーメッセージを表示しない |
| -v | パーミッションを変更した際の実行結果を表示 |
| -R | ディレクトリ内すべてのパーミッションを変更 |
記号表
| u | 所有者の権限 |
|---|---|
| g | グループの権限 |
| o | その他のユーザーの権限 |
| a | すべてのユーザーの権限 |
| + | 権限を追加 |
| – | 権限を削除 |
| = | 権限を変更 |
| r | 読み込み権限 |
| w | 書き込み権限 |
| x | 実行権限 |
| s | セットID |
数字表
| 0 | — |
|---|---|
| 1 | –x |
| 2 | -w- |
| 3 | -wx |
| 4 | r– |
| 5 | r-w |
| 6 | rw- |
| 7 | rwx |
example of use
[root@centos7 ~]# ls -l
-rw-r--r-- 1 user root 560 5月 30 22:00 text.txt
[root@centos7 ~]# chmod ugoa+wx text.txt
[root@centos7 ~]# ls -l
-rwxrwxrwx 1 user root 560 5月 30 22:00 text.txt
text.txtファイルを記号を使用してパーミッションを変更。
[root@centos7 ~]# ls -l
-rwxrwxrwx 1 user root 560 5月 30 22:00 text.txt
[root@centos7 ~]# chmod 644 text.txt
[root@centos7 ~]# ls -l
-rw-r--r-- 1 user root 560 5月 30 22:00 text.txt
text.txtファイルを数字を使用してパーミッションを変更。