사용 권한

ᄋᄋ·2022년 2월 28일
0

파일의 소유자와 파일에 적용된 사용 권한을 확인: ls -l
파일에 적용된 사용 권한을 변경: chmod


1. 폴더인지 파일인지 확인하기

mkdir linux
nano helloworld.js   ..'ctrl + x' 로 저장
ls -l


2. chmod: 권한을 변경하는 명령어

명령어 chmod 로 권한을 변경하는 방식은 두 가지임.

  • 더하기(+), 빼기(-), 할당(=)과 액세서 유형을 표기해서 변경하는 Symbolic method.
  • rwx를 3 bit로 해석하여, 숫자 3자리로 권한을 표기해서 변경하는 Absolute form.

Symbolic method는 액세스 클래스, 연산자, 액세스 타입으로 구분함.

<symbolic method 사용 예시>

chmod g-r filename # removes read permission from group
chmod g+r filename # adds read permission to group
chmod g-w filename # removes write permission from group
chmod g+w filename # adds write permission to group
chmod g-x filename # removes execute permission from group
chmod g+x filename # adds execute permission to group
chmod o-r filename # removes read permission from other
chmod o+r filename # adds read permission to other
chmod o-w filename # removes write permission from other
chmod o+w filename # adds write permission to other
chmod o-x filename # removes execute permission from other
chmod o+x filename # adds execute permission to other
chmod u+x filename # adds execute permission to user
chmod a=rw helloworld.js # -rw-rw-rw-
chmod u= helloworld.js # ----rw-rw-
chmod a+rx helloworld.js # -r-xrwxrwx
chmod go-wx helloworld.js # -r-xr--r--
chmod a= helloworld.js # ----------
chmod u+rwx helloworld.js # -rwx------

Absolute form은 숫자 7까지 나타내는 3 bits의 합으로 표기함.

<Absolute form 사용 예시>

# u=rwx (4 + 2 + 1 = 7), go=r (4 + 0 + 0 = 4)
chmod 744 helloworld.js # -rwxr--r--

Absolute form에서 사용하는 숫자는 다음의 표를 참고함.

*파일 권한과 관련된 레퍼런스

profile
개발자A

0개의 댓글