(20) ★ 파일과 디렉토리 에 r w x 권한 부여
UNIX
1. Permission
2. File & Directory
3. Read & Write & Excute
■ access mode
r : read
w : write
x : execute
◆ touch : 파일생성
◆ cat : 파일내용 확인
※ cat 명령어는 텍스트로 된 파일일 경우 그 내용을 정상적으로 출력하지만 바이너리 파일일 경우에는 출력은 하지만 알아볼 수 없다.
그리고 2개 이상의 파일이름이 지정되면 모든 파일이 연결되어 보여진다.
ex) chPark 계정으로 접속하였다고 가정
$ touch perm.txt // 파일 생성
$ echo 'hello world' > perm.txt // 'hello world' standard output 를 perm.txt 로 redirection
$ cat perm.text // perm.txt 내용 확인 (당연히 가능)
( ※ > 은 1> 과 같다. 1이 생략 되어있음. 2>: 은 standard error redirection 을 의미한다. )
ex) mgLee 계정으로 접속하였다고 가정
$ echo 'hello world' > perm.txt
permission denied // redirection 거절 당함
■ 파일정보 확인
- rw-rw-r-- 1 chPark success 0 May 6 19:23 perm.txt
1) 맨앞 - : type ( d: directory , -: file )
2) rw- : user(owner) 권한 read, write
3) rw- : group 권한 read, write
4) r-- : other 권한 read (other: 소유자도, 그룹도 아닌 불특정 계정의 권한을 말한다.)
5) chPark : owner
6) success : Group
7) perm.txt : file 명
■ 권한 변경하기 (modify access mode)
ex1) other 에게 read 권한을 부여하고 싶다면?
perm.txt 파일 소유자로 로그인
$ chmod o+r perm.txt ( a: all의 약자, o: other 의 약자, u: user의 약자, g: group의 약자 )
ex2) user 에게 read 권한을 없애고 싶다면?
perm.txt 파일 소유자로 로그인
$ chmod u-r perm.txt ( + : add , - : subtract )