카테고리 없음

chown / chmod 명령어

carro1t 2019. 6. 15. 03:41

software center에 없는 어플리케이션들을 설치할 때 자주 사용하게 되는 명령어.

주로 폴더, 또는 파일 이동 후 소유권과 파일 권한을 변경할 때 사용하게 되는 명령어인 chown, chmod이다.

 

두 명령어의 차이

chown: change owner, 파일 또는 폴더의 소유권을 변경하는 명령어.

chmod: change mode, 파일이나 폴더의 권한(읽기, 쓰기, 실행)을 변경하는 명령어.

 

1. 우선 파일, 폴더(디렉토리)의 권한과 소유권 보기

drwxr-xr-x@  11 hitk  staff       352  4 22 07:19 KnuSentiLex-master
drwx------@ 152 hitk  staff      4864  6 13 15:12 Library

 

권한 문자열(Permission string),

해당 디렉토리 내부의 파일과 디렉토리 갯수,

소유주,

소유주가 속한 그룹,

크기,

마지막에 접근한 시각,

파일/디렉토리의 이름 

 

drwx------@
:directory, 소유주 hitk의 권한 3가지(read, write, execute) 가능, 소유주 그룹의 권한은 ---, 위 두 그룹에 포함되지 않는 모든 유저의 권한(All oter users) ---

 

 

chown: 파일이나 디렉토리의 소유주를 바꾸는 명령어.

chown user:group /file/path 형식으로 명령을 실행하면 된다. 

만약, 소유주를 root 그룹의 root 로 바꾸려면, sudo chown root:root dir1(파일명) 이렇게 사용하면 됨.

 

chmod: 파일이나 디렉토리의 권한을 바꾸는 명령어이다. 

 

 

https://muckycode.blogspot.com/2016/09/linux-chown-vs-chmod.html 해당 문서를 참조했음

python

Python 3.7.3 (default, Mar 27 2019, 16:54:48) 

[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>>