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