14 アクセス権
14.7 各アクセス権の意味の確認
見てるだけでも大丈夫です。
username@t2a006168:~>cd ~/mylec/modetest/
username@t2a006168:~/mylec/modetest>ls -l total 64
-rwxr-xr-x 1 username users 11934 2014-04-08 21:00 a.out
-rw-r--- 1 username users 2304 2014-04-08 20:59 make_sh_mode_test.c username@t2a006168:~/mylec/modetest>./a.out | less
username@t2a006168:~/mylec/modetest>./a.out > modetest.sh username@t2a006168:~/mylec/modetest>less modetest.sh username@t2a006168:~/mylec/modetest>ls -l
コメント [A108]: SGID
コメント [A109]: SGIDが指定されたディ レクトリでファイルを作成すると、そのフ ァイルの所有グループはそのディレクトリ の所有グループになります。
コメント [A110]: パイプライン コメント [A111]: リダイレクト
コメント [A112]: シェルスクリプトの内容 を確認。
total 96
-rwxr-xr-x 1 username users 11934 2014-04-08 21:00 a.out
-rw-r--- 1 username users 2304 2014-04-08 20:59 make_sh_mode_test.c -rw-r--r-- 1 username users 9476 2014-04-09 20:04 modetest.sh
username@t2a006168:~/mylec/modetest>source modetest.sh username@t2a006168:~/mylec/modetest>ls -ld dir*
d--- 2 username users 32768 2014-04-09 20:05 dir_0000_--- d--x--- 2 username users 32768 2014-04-09 20:05 dir_0100_--x--- d-w--- 2 username users 32768 2014-04-09 20:05 dir_0200_-w--- d-wx--- 2 username users 32768 2014-04-09 20:05 dir_0300_-wx--- dr--- 2 username users 32768 2014-04-09 20:05 dir_0400_r--- dr-x--- 2 username users 32768 2014-04-09 20:05 dir_0500_r-x--- drw--- 2 username users 32768 2014-04-09 20:05 dir_0600_rw--- drwx--- 2 username users 32768 2014-04-09 20:05 dir_0700_rwx---
14.7.1 ディレクトリのrについて
たぶん時間がないので紹介だけ username@t2a006179:~/mylec/modetest>\ls dir_0000_---/
ls: cannot open directory dir_0000_---/: Permission denied username@t2a006179:~/mylec/modetest>\ls dir_0300_-wx---/
ls: cannot open directory dir_0300_-wx---/: Permission denied username@t2a006179:~/mylec/modetest>\ls dir_0400_r---/
file_0000_--- file_0100_--x--- file_0200_-w--- file_0300_-wx--- f ile_0400_r--- file_0500_r-x--- file_0600_rw--- file_0700_rwx--- username@t2a006179:~/mylec/modetest>\ls dir_0700_rwx---/
file_0000_--- file_0100_--x--- file_0200_-w--- file_0300_-wx--- f ile_0400_r--- file_0500_r-x--- file_0600_rw--- file_0700_rwx--- username@t2a006179:~/mylec/modetest>
14.7.2 ディレクトリのxについて
たぶん時間がないので紹介だけ username@t2a006179:~/mylec/modetest>cd dir_0000_---/
コメント [A113]: 新しくディレクトリがで きます。ディレクトリの中にファイルも作 られています。
コメント [A114]: aliasを使わないように するため。
コメント [A115]: 1文字目が-:ディレクト リの中身をリスト表示する権利がない
コメント [A116]: 1文字目が-:ディレクト リの中身をリスト表示する権利がない
コメント [A117]: 1文字目がr:ディレクト リの中身をリスト表示する権利がある
コメント [A118]: 1文字目がr:ディレクト リの中身をリスト表示する権利がある
64 -bash: cd: dir_0000_---/: Permission denied
username@t2a006179:~/mylec/modetest>cd dir_0100_--x---/
username@t2a006179:~/mylec/modetest/dir_0100_--x--->cd ..
username@t2a006179:~/mylec/modetest>cd dir_0600_rw---/
-bash: cd: dir_0600_rw---/: Permission denied
username@t2a006179:~/mylec/modetest>cd dir_0700_rwx---/
username@t2a006179:~/mylec/modetest/dir_0700_rwx--->cd ..
username@t2a006179:~/mylec/modetest>
14.7.3 ファイルのrについて
たぶん時間がないので紹介だけ
username@t2a006179:~/mylec/modetest>cat dir_0700_rwx---/file_0000_--- cat: dir_0700_rwx---/file_0000_---: Permission denied
username@t2a006179:~/mylec/modetest>cat dir_0700_rwx---/file_0300_-wx--- cat: dir_0700_rwx---/file_0300_-wx---: Permission denied
username@t2a006179:~/mylec/modetest>cat dir_0700_rwx---/file_0400_r--- echo "This file is file_0400_r---"
username@t2a006179:~/mylec/modetest>cat dir_0700_rwx---/file_0700_rwx--- echo "This file is file_0700_rwx---"
username@t2a006179:~/mylec/modetest>cat dir_0600_rw---/file_0700_rwx--- cat: dir_0600_rw---/file_0700_rwx---: Permission denied
username@t2a006179:~/mylec/modetest>cat dir_0100_--x---/file_0300_-wx--- cat: dir_0100_--x---/file_0300_-wx---: Permission denied
username@t2a006179:~/mylec/modetest>cat dir_0100_--x---/file_0400_r--- echo "This file is file_0400_r---"
コメント [A119]: 3文字目が-(またはSま たはT): カレントディレクトリにする権 利がない ディレクトリ内のファイルを利 用する権利がない
コメント [A120]: 3文字目がx(またはsま
たはt):カレントディレクトリにする権利
がある ディレクトリ内のファイルを利用 する権利がある
コメント [A121]: ディレクトリがrwxで も、ファイルにrがないので、読めない。
コメント [A122]: ディレクトリにxがない から、中のファイルが rwxでも読めない。
コメント [A123]: ディレクトリのxとファ イルのrさえあれば、ファイルが読める。
(ディレクトリにrがない:ファイル名を
知っているからファイルが読める)
14.7.4 ファイルのxについて
見てるだけでも大丈夫です。
username@t2a006179:~/mylec/modetest>./dir_0700_rwx---/file_0000_--- -bash: ./dir_0700_rwx---/file_0000_---: Permission denied
username@t2a006179:~/mylec/modetest>./dir_0700_rwx---/file_0100_--x--- /bin/sh: ./dir_0700_rwx---/file_0100_--x---: Permission denied
username@t2a006179:~/mylec/modetest>./dir_0700_rwx---/file_0400_r--- -bash: ./dir_0700_rwx---/file_0400_r---: Permission denied
username@t2a006179:~/mylec/modetest>./dir_0700_rwx---/file_0500_r-x--- This file is file_0500_r-x---
username@t2a006179:~/mylec/modetest>./dir_0600_rw---/file_0700_rwx--- -bash: ./dir_0600_rw---/file_0700_rwx---: Permission denied
username@t2a006179:~/mylec/modetest>./dir_0100_--x---/file_0500_r-x--- This file is file_0500_r-x---
この部分はたぶん時間がないので紹介だけ username@t2a006179:~/mylec/modetest>ls -l a.out
--wxr-xr-x 1 username users 11934 2013-11-11 18:31 a.out username@t2a006179:~/mylec/modetest>chmod 055 a.out username@t2a006179:~/mylec/modetest>ls -l a.out
----r-xr-x 1 username users 11934 2013-11-11 18:31 a.out username@t2a006179:~/mylec/modetest>./a.out
-bash: ./a.out: Permission denied
username@t2a006179:~/mylec/modetest>chmod u+x a.out username@t2a006179:~/mylec/modetest>ls -l a.out
---xr-xr-x 1 username users 11934 2013-11-11 18:31 a.out username@t2a006179:~/mylec/modetest>./a.out
#! /bin/sh
~~ ~~
chmod 0700 dir_0700_rwx---
コメント [A124]: xだけだとシェルスクリ プトは実行できない。
コメント [A125]: rだけだとこの方法では シェルスクリプトは実行できない。(shや
sourceや.を使う必要がある)
コメント [A126]: [ここが重要です]
rとxの2つがあって、この方法でシェル スクリプトが実行できる。
コメント [A127]: ディレクトリにxがない ので、実行できない。
コメント [A128]: ディレクトリのxとファ イルのrとxの2つがあって、この方法 で実行できる。
コメント [A129]: xがないので、実行でき ない。(a.outのファイルの所有者の操作な ので、所有グループのユーザーのアクセス 権やその他のユーザーのアクセス権は無関 係。)
コメント [A130]: xだけで実行できる。
(シェルスクリプトとは違う)
66 username@t2a006179:~/mylec/modetest>chmod 355 a.out username@t2a006179:~/mylec/modetest>ls -l a.out
--wxr-xr-x 1 username users 11934 2013-11-11 18:31 a.out username@t2a006179:~/mylec/modetest>
14.7.5 ファイルのwについて
たぶん時間がないので紹介だけ username@t2a006179:~/mylec/modetest>echo over_write_test over_write_test
username@t2a006179:~/mylec/modetest>echo over_write_test > test username@t2a006179:~/mylec/modetest>cat test
over_write_test
username@t2a006179:~/mylec/modetest>echo over_write_test > dir_0700_rwx---/file_000 0_---
-bash: dir_0700_rwx---/file_0000_---: Permission denied
username@t2a006179:~/mylec/modetest>echo over_write_test > dir_0700_rwx---/file_020 0_-w---
username@t2a006179:~/mylec/modetest>cat dir_0700_rwx---/file_0200_-w--- cat: dir_0700_rwx---/file_0200_-w---: Permission denied
username@t2a006179:~/mylec/modetest>ls -l dir_0700_rwx---/file_0200_-w--- --w--- 1 username users 16 2013-11-11 20:07 dir_0700_rwx---/file_0200_-w--- username@t2a006179:~/mylec/modetest>chmod u+r dir_0700_rwx---/file_0200_-w--- username@t2a006179:~/mylec/modetest>ls -l dir_0700_rwx---/file_0200_-w--- -rw--- 1 username users 16 2013-11-11 20:07 dir_0700_rwx---/file_0200_-w--- username@t2a006179:~/mylec/modetest>cat dir_0700_rwx---/file_0200_-w--- over_write_test
username@t2a006179:~/mylec/modetest>chmod u-r dir_0700_rwx---/file_0200_-w--- username@t2a006179:~/mylec/modetest>ls -l dir_0700_rwx---/file_0200_-w--- --w--- 1 username users 16 2013-11-11 20:07 dir_0700_rwx---/file_0200_-w--- username@t2a006179:~/mylec/modetest>echo over_write_test > dir_0700_rwx---/file_050 0_r-x---
-bash: dir_0700_rwx---/file_0500_r-x---: Permission denied
コメント [A131]: ファイルにwがないの で書き込めない
コメント [A132]: ファイルにrが無いので 読み込めない
コメント [A133]: 書き込めたことを確認
コメント [A134]: ファイルにwがないの で書き込めない
username@t2a006179:~/mylec/modetest>echo over_write_test > dir_0100_--x---/file_020 0_-w---
username@t2a006179:~/mylec/modetest>ls -l dir_0100_--x---/file_0200_-w--- --w--- 1 username users 16 2013-11-11 20:16 dir_0100_--x---/file_0200_-w--- username@t2a006179:~/mylec/modetest>cat dir_0100_--x---/file_0200_-w---
cat: dir_0100_--x---/file_0200_-w---: Permission denied
username@t2a006179:~/mylec/modetest>chmod u+r dir_0100_--x---/file_0200_-w--- username@t2a006179:~/mylec/modetest>cat dir_0100_--x---/file_0200_-w--- over_write_test
username@t2a006179:~/mylec/modetest>chmod u-r dir_0100_--x---/file_0200_-w--- username@t2a006179:~/mylec/modetest>ls -l dir_0100_--x---/file_0200_-w--- --w--- 1 username users 16 2013-11-11 20:16 dir_0100_--x---/file_0200_-w--- username@t2a006179:~/mylec/modetest>
username@t2a006179:~/mylec/modetest>echo over_write_test > dir_0600_rw---/file_070 0_rwx---
-bash: dir_0600_rw---/file_0700_rwx---: Permission denied
username@t2a006180:~/mylec/modetest>ls -l dir_0100_--x---/file_0400_r--- -r--- 1 username users 59 2013-11-20 20:22 dir_0100_--x---/file_0400_r--- username@t2a006179:~/mylec/modetest>cat dir_0100_--x---/file_0400_r---
echo "This file is file_0400_r---"
username@t2a006179:~/mylec/modetest>vi dir_0100_--x---/file_0400_r---
# :wq :wq! w
#
username@t2a006179:~/mylec/modetest>cat dir_0100_--x---/file_0400_r--- echo "This file is file_0400_r---"
echo "clover test"
username@t2a006179:~/mylec/modetest>
14.7.6 ディレクトリのwについて
コメント [A135]: ディレクトリにxがあっ て、ファイルにwがあれば書き込める。
コメント [A136]: ファイルにrが無いので 読み込めない
コメント [A137]: ディレクトリにxがない ので、その中のファイルにwがあっても 書き込めない。
68 たぶん時間がないので紹介だけ username@t2a006179:~/mylec/modetest>vi newfile_test username@t2a006179:~/mylec/modetest>cat newfile_test new_file
username@t2a006179:~/mylec/modetest>cp newfile_test dir_0000_---/
cp: cannot stat `dir_0000_---/newfile_test': Permission denied username@t2a006179:~/mylec/modetest>cp newfile_test dir_0100_--x---/
cp: cannot create regular file `dir_0100_--x---/newfile_test': Permission denied username@t2a006179:~/mylec/modetest>cp newfile_test dir_0200_-w---/
cp: cannot stat `dir_0200_-w---/newfile_test': Permission denied username@t2a006179:~/mylec/modetest>cp newfile_test dir_0300_-wx---/
username@t2a006179:~/mylec/modetest>ls dir_0300_-wx---/newfile_test dir_0300_-wx---/newfile_test
username@t2a006179:~/mylec/modetest>cat dir_0300_-wx---/newfile_test new_file
username@t2a006179:~/mylec/modetest>rm dir_0000_---/file_0000_--- rm: cannot remove `dir_0000_---/file_0000_---': Permission denied username@t2a006179:~/mylec/modetest>rm dir_0000_---/file_0700_rwx--- rm: cannot remove `dir_0000_---/file_0700_rwx---': Permission denied username@t2a006179:~/mylec/modetest>rm dir_0100_--x---/file_0000_--- rm: remove write-protected regular file `dir_0100_--x---/file_0000_---'? y rm: cannot remove `dir_0100_--x---/file_0000_---': Permission denied username@t2a006179:~/mylec/modetest>rm dir_0100_--x---/file_0700_rwx--- rm: cannot remove `dir_0100_--x---/file_0700_rwx---': Permission denied username@t2a006179:~/mylec/modetest>rm dir_0200_-w---/file_0000_--- rm: cannot remove `dir_0200_-w---/file_0000_---': Permission denied username@t2a006179:~/mylec/modetest>rm dir_0200_-w---/file_0700_rwx--- rm: cannot remove `dir_0200_-w---/file_0700_rwx---': Permission denied username@t2a006179:~/mylec/modetest>rm dir_0300_-wx---/file_0000_--- rm: remove write-protected regular file `dir_0300_-wx---/file_0000_---'? y username@t2a006179:~/mylec/modetest>rm dir_0300_-wx---/file_0700_rwx--- username@t2a006179:~/mylec/modetest>ls dir_0300_-wx---/file_0000_--- ls: cannot access dir_0300_-wx---/file_0000_---: No such file or directory
コメント [A138]: ディレクトリにwがあ るだけだと、新しいファイルの作成ができ ない。
コメント [A139]: ディレクトリにwとx があると、新しいファイルの作成ができる。
コメント [A140]: ファイルに wがないと、
消すか尋ねられる。
コメント [A141]: 消せない。(ディレクト リにwがない(xだけでは消せない))
コメント [A142]: ディレクトリにwがあ るだけだと消せない。
コメント [A143]: ディレクトリにwとx があるので、消せる。ファイルにwがな いので消すか尋ねられる。
コメント [A144]: ディレクトリにwとx があるので、消せる。ファイルにwがあ るので消すか尋ねられない
username@t2a006179:~/mylec/modetest>ls dir_0300_-wx---/file_0700_rwx--- ls: cannot access dir_0300_-wx---/file_0700_rwx---: No such file or directory