Study Memory Work
[Linux] Permission 권한 본문

모든 사용자는 이 파일을 읽을 수 있다. 이 파일의 소유자와 그룹은 파일을 쓸 수 있다.
- Type : 일반 파일 [-], 디렉토리 [d]
- Access mode : 권한
1) Owner 권한
2) Group 권한
3) Other 권한 : 오너도 아닌 그룹도 아닌 모든 사용자
* r : read 읽기, w : write 쓰기, x : excute 실행하기 - 소유자 정보
1) Owner : 소유자
2) Group : 소유자가 속한 그룹 - 생성날짜
- 이름
권한 설정/변경 하기 ::: chmod
chmod [사용자][+/-][권한종류] 파일명
//ex
chmod o-r test.txt
[사용자]
o : other
u : owner(User)
r : group
a : o+u+r 모든 사용자
[+/-]
+ : 권한추가
- : 권한회수
[권한 종류]
r / w / x : 읽기 / 쓰기 / 실행
Excute 실행 권한 ::: x
- 실행 가능한 파일을 실행하는 권한.
- test할 실행파일 생성

위 파일을 아래와 같이 지정한 실행 경로와 함께(bin/bash) 프로그램을 실행시키는 것은 누구나 가능하나,
$ /bin/bash hello.txt
현 디렉토리에서 다이렉트로 프로그램을 실행시키려면 권한이 필요하다.
$ ./hello.sh
bash: ./hello.sh: Permission denied // 권한 없음 에러
- 권한 설정
chmod u+x hello.sh // hello.sh 실행파일에 대해 오너(유저)에게 실행 권한 설정
$ ./hello.sh
hello world! // 정상 실행

위처럼 권한을 설정하면 ls -l 에서 권한이 설정된 것을 볼 수 있다.
디렉토리 권한
r : 내부 파일 및 정보 조회 권한.
w : 내부에 파일을 생성 권한.
x : 디렉토리에 접근 권한
chmod
출처 입력
- 명령어 구조
$ chmod [options] mode[,mode] file1 [file2 ...]
- 8진법 숫자를 이용하여 권한 한번에 설정하기
|
읽기 (r)
|
쓰기 (w)
|
실행 (x)
|
|
유저 (u)
|
4
|
2
|
1
|
|
그룹 (g)
|
4
|
2
|
1
|
|
other (o)
|
4
|
2
|
1
|
chmod 111 test.txt // --x--x--x
chmod 222 test.txt // -w--w--w-
chmod 333 test.txt // -wx-wx-wx 1+2
chmod 444 text.txt // r--r--r--
chmod 555 test.txt // r-xr-xr-x 1+4
chmod 666 test.txt // rw-rw-rw- 2+4
chmod 777 test.txt // rwxrwxrwx 1+2+4
- 알파벳으로 권한 한번에 설정
chmod a+r test.txt
chmod a-r test.txt
chmod a=rwx test.txt
chdmo a= text.txt
'Linux (Ubuntu, macOS)' 카테고리의 다른 글
[Linux] 실무에 자주 쓰는 명령어 (0) | 2022.10.06 |
---|---|
[Linux] SSH / 사용자PC에서 서버PC 제어하기 / 서버 컴퓨터 원격 접속 (1) | 2022.09.29 |
[Linux] Multi User / 다중 사용자 시스템 (0) | 2022.09.29 |
[Linux] 항상 실행되는 개념 / Deamon (0) | 2022.09.29 |
[Linux] 백그라운드 작업 (1) | 2022.09.29 |