·터미널 명령어

chmod

권한·소유

쓰는 꼴

chmod 755 [path]

파일과 디렉터리의 권한 비트를 정합니다. chmod -R 755는 평범한 파일까지 실행 가능으로 만들므로, 파일은 그대로 두려면 대문자 X를 씁니다.

자주 쓰는 옵션

옵션
0755Numeric: owner, group, others, each read 4 + write 2 + execute 1
u+wSymbolic: who (u g o a), then + - =, then r w x
+xAdd the execute bit, the usual fix for a script
-RApply to a whole tree
+XExecute for directories only, never for plain files
-vName each file whose mode changed
-hBSD and macOS: change the symlink itself, not its target

예시

chmod +x deploy.sh

Makes the script runnable.

chmod -R u+rwX,go+rX,go-w site/

Capital X keeps files non-executable.

chmod 600 ~/.ssh/id_ed25519

What ssh insists on for a private key.

숫자 모드와 문자 모드가 같은 것을 가리킵니다. 755와 u=rwx,go=rx는 같은 뜻입니다.

읽는 방법

  • 대괄호 [ ]는 넣어도 되고 안 넣어도 되는 자리입니다.
  • 점 셋 …은 여러 개를 이어 쓸 수 있다는 뜻입니다.
  • 옵션은 대소문자를 가립니다 — -r과 -R이 다른 명령도 있습니다.

자주 묻는 것

Q. chmod은 무엇을 하나요?

파일과 디렉터리의 권한 비트를 정합니다. chmod -R 755는 평범한 파일까지 실행 가능으로 만들므로, 파일은 그대로 두려면 대문자 X를 씁니다.

Q. 어떻게 치나요?

chmod 755 [path] — 대괄호는 생략할 수 있는 자리입니다.

Q. 옵션은 몇 개나 자주 쓰나요?

여기 정리한 것은 7개입니다. 전체 목록은 man chmod에 있습니다. 이 명령은 권한·소유 갈래입니다.

같이 보는 명령

man 페이지: man chmod