OS/Linux

[Linux] 리눅스 명령어 - chown, chmod

개발계발게발 2021. 11. 8. 13:39
반응형

리눅스 명령어 - chown (change ownership)

 

리눅스(Linux)에서 chown는 파일 및 디렉터리의 소유자와 그룹을 변경할 때 사용하는 명령어

 

사용 구문

chown [옵션] [소유자]:[소유그룹] [파일 또는 디렉토리]

 

  • test.txt 파일의 소유자를 hoon으로 하고 소유 그룹을 group으로 변경
chown hoon:group test.txt

 

  • dir1/dir2 디렉토리의 소유자를 hoon으로 하고, 소유 그룹을 group으로 변경
chown hoon:group dir1/dir2

 

  • dir1/dir2 하위 모든 디렉토리 및 파일들의 소유자를 hoon으로 하고, 소유그룹을 group으로 변경
chown -R hoon:group dir1/dir2

 


리눅스 명령어 - chmod (change mode)

 

리눅스(Linux)에서 chmod는 파일의 권한을 변경할 때 사용하는 명령어

 

사용 구문

chown [모드] [파일]

 

  • test.txt 파일의  권한 : 사용자(권한 없음), 그룹(권한 없음), 그외 사용자(권한 없음) 
chown 000 test.txt

 

  • test.txt 파일의  권한 : 사용자(읽기), 그룹(읽기), 그외 사용자(읽기) 
chmod 444 test.txt

 

  • test.txt 파일의 권한 : 사용자(읽기+실행), 그룹(읽기+실행), 그외 사용자(읽기+실행) 
chmod 555 test.txt

 

  • test.txt 파일의 권한 : 사용자(읽기+쓰기), 그룹(읽기+쓰기), 그외 사용자(읽기+쓰기) 
chmod 666 test.txt

 

  • test.txt 파일의 권한 : 사용자(읽기+쓰기+실행), 그룹(읽기+쓰기+실행), 그외 사용자(읽기+쓰기+실행) 
chmod 777 test.txt

 

  • test.txt 파일의 권한 : 사용자(읽기+쓰기), 그룹(읽기+쓰기), 그외 사용자(읽기) 
chmod 664 test.txt

 

  • test.txt 파일의 권한 : 사용자(읽기+쓰기+실행), 그룹(읽기), 그외 사용자(읽기+실행) 
chmod 745 test.txt

 

반응형