본문 바로가기
리눅스

리눅스 사용권한 2) chmod: 권한을 변경하는 명령어

by 왕밤 2021. 10. 5.

권한 변경이 가능한 경우

 

OS에 로그인한 사용자와, 폴더나 파일의 소유자가 같을 경우

명령어 chmod 로 폴더나 파일의 권한을 변경할 수 있다

 

만약 OS에 로그인한 사용자와, 폴더나 파일의 소유자가 다를 경우에는

관리자 권한을 획득하는 명령어 sudo 를 이용해 폴더나 파일의 권한을 변경할 수 있다

 

변경 방법

 

  • Symbolic method

 더하기(+), 빼기(-), 할당(=)과 액세서 유형을 표기해서 변경

액세스 클래스와 연산자, 액세스 타입을 모두 기억해야만 Symbolic method를 이용해 권한을 변경할 수 있다

 

예) -r--r--r--

chmod u+w filename      👉   -rw--r--r--
chmod u= filename         👉   ---r--r--
chmod a= filename         👉   ---------
chmod u=rwx filename   👉   -rwx-----
chmod a+wx filename   👉   -rwx-wx-wx

 

  • Absolute form

rwx를 3 bit로 해석하여, 숫자 3자리로 권한을 표기해서 변경

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

 

 


https://kb.iu.edu/d/abdb

 

Manage file permissions on Unix-like systems

On this page: Overview Unix-like operating systems, such as Linux, running on shared high-performance computers use settings called permissions to determine who can access and modify the files and directories stored in their file systems. Each file and dir

kb.iu.edu

 

댓글