▼すべてを開く。
▲すべてを閉じる。
$ ls -l drw-r-xr-x 2 masa users 4096 5月 20 17:50 dir1
$ chmod u+x dir1
chmodコマンドで、所有者を表す「u」に実行権の付加を表す「+x」対象ディレクトリ名「dir1」を指定すると、ディレクトリ「dir1」に所有者の実行許可が設定される。
lsコマンドで実行結果を見る$ ls -l drwxr-xr-x 2 masa users 4096 5月 20 17:50 dir1
ディレクトリの所有者本人がコマンドを実行する場合「u」を省略することができる。
$ chmod +x dir1
$ ls -l -rw-rw-r-- 1 masa users 268 6月 3 21:48 myfile1
$ chmod u+x myfile1
chmodコマンドで、ファイルの所有者を示す「u」に実行権の付加を表す「+x」対象ファイル名「myfile1」を指定すると、ファイル「myfile1」に所有者の実行許可が設定される。
lsコマンドで実行結果を見る$ ls -l -rwxrw-r-- 1 masa users 268 6月 3 21:48 myfile1
自らが所有するファイルを変更する場合、ファイルの所有者を示す「u」を省略して実行権の付加を表す「+x」だけでもよい。
$ chmod +x myfile1
$ ls -l -rwxrwxrwx 1 masa users 256 5月 19 19:00 file
$ chmod u=x file
chmodコマンドで、ファイルの所有者を示す「u」に特定の権限だけの設定を示す「=」そして実行「x」対象ファイル名「file」を指定すると、所有者のファイル「file」に対するアクセス権が実行だけに設定される。
コマンド実行結果をリストで見る$ ls -l ---xrwxrwx 1 masa users 256 5月 19 19:00 file