권한.md
1) 폴더/파일에서 권한 표시가 있음
- 권한 : 소유권과 관계가 있음
- 기본 규칙 : 작성한 사람이 소유권을 가짐 , 쓰기(write), 읽기(read), 실행(excute)권한을 모두 할 수 있음
- 권한 : 작성자(소유자, user), 작성자그룹(group), 다른사람들(other)
- root : 슈퍼계정(사용자,관리자계정), 회사에서 root 계정가진사람, 전산실관리자 1~2명만 가짐
예제 1) 리눅스에서는 모든 명령어, 장치(마우스, 키보드) 들이 모두 파일로 이루어져 있음, /bin/cat 명령어 파일을 상세보기 하세요
oracle@2d5f598932bb:/bin$ ls -l cat
-rwxr-xr-x 1 root root 35064 Jan 18 2018 cat
[작성자][작성자그룹]
-rwxr-xr-x : -rwx r-x r-x
[작성자] [그룹] [다른사람들]
r:read(읽기), w:write(쓰기), x:excute(실행)
2) 파일의 권한 변경 :
예제 2) work 폴더에서 newfile1 만들고 user(사용자) 에 대해 읽기 권한을 뺏기를 하세요
사용법) chmod [사용자(u,g,o)][+/-][권한(r,w,x)] 파일명
chmod == change mode
사용자(u,g,o) - u: user, g: group, o:other
권한(r,w,x) - r: read, w: write, x:excute
oracle@2d5f598932bb:~$ touch newfile1
oracle@2d5f598932bb:~$ ls
newfile1 work
oracle@2d5f598932bb:~$ ls -l
total 4
-rw-r--r-- 1 oracle dba 0 Feb 22 06:23 newfile1
drwxr-xr-x 4 oracle dba 4096 Feb 22 01:00 work
oracle@2d5f598932bb:~$
oracle@2d5f598932bb:~$ chmod u-r newfile1
oracle@2d5f598932bb:~$ ls
newfile1 work
oracle@2d5f598932bb:~$ ls -l
total 4
--w-r--r-- 1 oracle dba 0 Feb 22 06:23 newfile1
drwxr-xr-x 4 oracle dba 4096 Feb 22 01:00 work
oracle@2d5f598932bb:~$ cat newfile1
cat: newfile1: Permission denied
oracle@2d5f598932bb:~$
연습 1) newfile2 만들고(touch) user 에대해서 읽기 권한을 뺏기하세요
oracle@2d5f598932bb:~$ chmod u-r newfile2
oracle@2d5f598932bb:~$ ls -l
total 4
--w-r--r-- 1 oracle dba 0 Feb 22 06:23 newfile1
--w-r--r-- 1 oracle dba 0 Feb 22 06:35 newfile2
drwxr-xr-x 4 oracle dba 4096 Feb 22 01:00 work
예제 2) newfile1 에 읽기 권한 다시 주기
oracle@2d5f598932bb:~$ chmod u+r newfile1
oracle@2d5f598932bb:~$ ls -l
total 4
-rw-r--r-- 1 oracle dba 0 Feb 22 06:23 newfile1
--w-r--r-- 1 oracle dba 0 Feb 22 06:35 newfile2
drwxr-xr-x 4 oracle dba 4096 Feb 22 01:00 work
연습 2) newfile2 에 읽기 권한 다시 주기
oracle@2d5f598932bb:~$ chmod u+r newfile2
oracle@2d5f598932bb:~$ ls -l
total 4
-rw-r--r-- 1 oracle dba 0 Feb 22 06:23 newfile1
-rw-r--r-- 1 oracle dba 0 Feb 22 06:35 newfile2
drwxr-xr-x 4 oracle dba 4096 Feb 22 01:00 work
oracle@2d5f598932bb:~$
3) (참고) 권한 주기/뺒기 #2 : 숫자로 권한 행사
읽기(r) : 4, 쓰기(w): 2, 실행(x): 1
rwx rwx rwx
[user] [group] [other]
4 4 4 => r--r--r--
2 2 2 => -w--w--w-
6 6 6 => rw-rw-rw-
7 7 7 => rwxrwxrwx
예제 3) newfile3 만들고 모든 권한 모든 사람에게 주세요.
(모두 : rwx 권한을 부여하세요)
oracle@2d5f598932bb:~$ chmod 777 newfile3
oracle@2d5f598932bb:~$ ls -l
total 4
-rw-r--r-- 1 oracle dba 0 Feb 22 06:23 newfile1
-rw-r--r-- 1 oracle dba 0 Feb 22 06:35 newfile2
-rwxrwxrwx 1 oracle dba 0 Feb 22 07:08 newfile3
drwxr-xr-x 4 oracle dba 4096 Feb 22 01:00 work
oracle@2d5f598932bb:~$