▼すべてを開く。
▲すべてを閉じる。
$ ls -l drwxr-xr-x 2 masa users 4096 5月 20 17:50 dir1
$ chmod g-r dir1
chmodコマンドで、グループを表す「g」に読み込み権の剥奪を表す「-r」対象ディレクトリ名「dir1」を指定すると、ディレクトリ「dir1」にグループの読み込み不可が設定される。
コマンド読み込み結果をリストで見る$ ls -l drwx--xr-x 2 masa users 4096 5月 20 17:50 dir1
$ ls -l drwxr-xr-x 2 masa users 4096 5月 20 17:50 dir1
$ chmod o-r dir1
chmodコマンドで、その他のグループを表す「o」に読み込み権の剥奪を表す「-r」対象ディレクトリ名「dir1」を指定すると、ディレクトリ「dir1」にその他のグループの読み込み不可が設定される。
コマンド読み込み結果をリストで見る$ ls -l drwxr-x--x 2 masa users 4096 5月 20 17:50 dir1
$ ls -l drwxr-xr-x 2 masa users 4096 5月 20 17:50 dir1
$ chmod u-r dir1
chmodコマンドで、所有者を表す「u」に読み込み権の剥奪を表す「-r」対象ディレクトリ名「dir1」を指定すると、ディレクトリ「dir1」に所有者の読み込み不可が設定される。
コマンド読み込み結果をリストで見る$ ls -l d-wxr-xr-x 2 masa users 4096 5月 20 17:50 dir1
ディレクトリの所有者本人がコマンドを読み込みする場合「u」を省略することができる。
$ chmod -r dir1
$ ls -l drwxr-xr-x 2 masa users 4096 5月 20 17:50 dir1
$ chmod a-r dir1
chmodコマンドで、全員を表す「a」に読み込み権の剥奪を表す「-r」対象ディレクトリ名「dir1」を指定すると、ディレクトリ「dir1」に全員の読み込み不可が設定される。
コマンド読み込み結果をリストで見る$ ls -l d-wx--x--x 2 masa users 4096 5月 20 17:50 dir1
$ ls -l -rwxr--r-- 1 masa users 268 6月 3 21:48 myfile1
$ chmod g-r myfile1
chmodコマンドで、グループを示す「g」に読み込み不可を表す「-r」対象ファイル名「myfile1」を指定すると、ファイル「myfile1」にグループの読み込み不可が設定される。この例では、ユーザ「masa」はグループ「users」に属しているので、このグループに属するユーザがファイルを読むことができないようになる。
lsコマンドで実行結果を見る$ ls -l -rwx---r-- 1 masa masa 268 6月 3 21:48 myfile1
$ ls -l -rwxr--r-- 1 masa users 268 6月 3 21:48 myfile1
$ chmod o-r myfile1
chmodコマンドで、その他のグループを示す「o」に読み込み不可を表す「-r」対象ファイル名「myfile1」を指定すると、ファイル「myfile1」にその他のグループの読み込み不可が設定される。この例では、ユーザ「masa」はグループ「users」に属しているので、このグループに属するユーザ以外のユーザがファイルを読むことができないようになる。
lsコマンドで実行結果を見る$ ls -l -rwxr----- 1 masa masa 268 6月 3 21:48 myfile1
$ ls -l -rwxr--r-- 1 masa users 268 6月 3 21:48 myfile1
$ chmod u-r myfile1
chmodコマンドで、ファイルの所有者を示す「u」に読み込み不可を表す「-r」対象ファイル名「myfile1」を指定すると、ファイル「myfile1」に所有者の読み込み不可が設定される。
lsコマンドで実行結果を見る$ ls -l --wxr--r-- 1 masa masa 268 6月 3 21:48 myfile1
自らが所有するファイルを変更する場合、ファイルの所有者を示す「u」を省略して読み込み不可を表す「-r」だけでもよい。
$ chmod -r myfile1
$ ls -l -rwxr--r-- 1 masa users 268 6月 3 21:48 myfile1
$ chmod a-r myfile1
chmodコマンドで、すべてのユーザを示す「a」に読み込み不可を表す「-r」対象ファイル名「myfile1」を指定すると、ファイル「myfile1」にすべてのユーザの読み込み不可が設定される。
lsコマンドで実行結果を見る$ ls -l --wx------ 1 masa masa 268 6月 3 21:48 myfile1