chown 명령어 (AIX 5.3·6.1)

핵심 정리

  • 파일이나 디렉터리의 소유자를 바꿉니다. 소유자:그룹으로 그룹도 함께 바꿀 수 있습니다. 이름이나 숫자 ID를 씁니다.
  • 소유자는 root만 바꿀 수 있습니다. 그룹은 root나 파일 소유자가 바꿀 수 있고, 소유자는 자기가 속한 그룹으로만 바꿀 수 있습니다.
  • -R은 디렉터리 아래까지 재귀적으로 바꿉니다. -f는 사용법 외 오류 메시지를 숨깁니다.
  • 심볼릭 링크는 기본으로 가리키는 대상을 바꾸고, -h를 주면 링크 자체를 바꿉니다.
  • -R과 함께 -H(명령줄 링크만 따라감), -L(모든 디렉터리 링크 따라감), -P(링크를 따라가지 않음)로 링크 처리를 정합니다.
  • AIX 5.3과 6.1 문서의 내용이 같습니다.
항목 내용
버전 AIX 5.3, AIX 6.1 (내용 같음, 6.1 보안 절에 RBAC 문단이 더해짐)
원문 IBM Commands Reference — 5.3 Volume 1, 6.1 Volume 1
파일 /usr/bin/chown, /etc/passwd, /etc/group
관련 명령어 chgrp, chmod

목적

파일의 소유자나 그룹을 바꿉니다.

영어 원문

Changes the owner or group associated with a file.

구문

text
chown [ -f ] [ -h ] [ -R ] Owner [ :Group ] { File ... | Directory ... }
chown -R [ -f ] [ -H | -L | -P ] Owner [ :Group ] { File ... | Directory ... }

설명

chown 명령은 File이나 Directory 매개변수로 지정한 파일이나 디렉터리의 소유자를 Owner 매개변수로 지정한 사용자로 바꿉니다. Owner 값은 사용자 데이터베이스의 사용자 이름이나 숫자 사용자 ID입니다. 원하면 그룹도 함께 지정할 수 있으며, Group 값은 그룹 데이터베이스의 그룹 이름이나 숫자 그룹 ID입니다.

파일의 소유자는 root 사용자만 바꿀 수 있습니다. 파일의 그룹은 root 사용자이거나 파일 소유자일 때만 바꿀 수 있습니다. 파일 소유자이지만 root가 아니면, 자신이 구성원인 그룹으로만 바꿀 수 있습니다.

-H, -L, -P는 서로 배타적이지만 둘 이상 지정해도 오류가 아닙니다. 마지막에 지정한 플래그가 동작을 정합니다.

심볼릭 링크를 만났을 때 -h 플래그가 없으면, 링크 자체가 아니라 링크가 가리키는 파일이나 디렉터리의 소유권을 바꿉니다. -h를 지정하면 반대로 링크 자체의 소유권을 바꾸고 링크가 가리키는 대상은 바꾸지 않습니다.

-R을 지정하면 지정한 디렉터리를 재귀적으로 내려갑니다. -h와 -R을 함께 지정하면 재귀적으로 내려가며, 심볼릭 링크를 만나면 링크가 가리키는 대상이 아니라 링크 자체의 소유권을 바꿉니다.

영어 원문

The chown command changes the owner of the file or directory specified by the File or Directory parameter to the user specified by the Owner parameter. The value of the Owner parameter can be a user name from the user database or a numeric user ID. Optionally, a group can also be specified. The value of the Group parameter can be a group name from the group database or a numeric group ID.

Only the root user can change the owner of a file. You can change the group of a file only if you are a root user or if you own the file. If you own the file but are not a root user, you can change the group only to a group of which you are a member.

Although the -H, -L and -P flags are mutually exclusive, specifying more than one is not considered an error. The last flag specified determines the behavior that the command will exhibit.

When a symbolic link is encountered and you have not specified the -h flag, the chown command changes the ownership of the file or directory pointed to by the link and not the ownership of the link itself.

If you specify the -h flag, the chown command has the opposite effect and changes the ownership of the link itself and not that of the file or directory pointed to by the link.

If you specify the -R flag, the chown command recursively descends the specified directories.

If you specify both the -h flag and the -R flag, the chown command descends the specified directories recursively, and when a symbolic link is encountered, the ownership of the link itself is changed and not that of the file or directory pointed to by the link.

플래그

플래그 설명
-f 사용법 메시지를 뺀 모든 오류 메시지를 숨깁니다.
-h 만난 심볼릭 링크 자체의 소유권을 바꾸고, 링크가 가리키는 파일이나 디렉터리는 바꾸지 않습니다.
-H -R과 함께 쓸 때, 명령줄에 지정한 심볼릭 링크가 디렉터리를 가리키면 그 디렉터리와 그 아래 모든 파일의 사용자 ID(지정하면 그룹 ID도)를 바꿉니다.
-L -R과 함께 쓸 때, 명령줄에 지정했거나 탐색 중에 만난 심볼릭 링크가 디렉터리를 가리키면 그 디렉터리와 그 아래 모든 파일의 사용자 ID(지정하면 그룹 ID도)를 바꿉니다.
-P -R과 함께 쓸 때, 명령줄에 지정했거나 탐색 중에 만난 심볼릭 링크는 시스템이 지원하면 링크 자체의 소유자 ID(지정하면 그룹 ID도)를 바꿉니다. 링크를 따라 파일 계층의 다른 곳으로 가지 않습니다.
-R 디렉터리를 재귀적으로 내려가며 파일마다 소유권을 바꿉니다. 디렉터리를 가리키는 심볼릭 링크를 만나면 그 디렉터리의 소유권은 바꾸지만 더 내려가지 않습니다.
영어 원문
  • -f — Suppresses all error messages except usage messages.
  • -h — Changes the ownership of an encountered symbolic link and not that of the file or directory pointed to by the symbolic link.
  • -H — If the -R option is specified and a symbolic link referencing a file of type directory is specified on the command line, the chown command shall change the user ID (and group ID, if specified) of the directory referenced by the symbolic link and all files in the file hierarchy below it.
  • -L — If the -R option is specified and a symbolic link referencing a file of type directory is specified on the command line or encountered during the traversal of a file hierarchy, the chown command shall change the user ID (and group ID, if specified) of the directory referenced by the symbolic link and all files in the file hierarchy below it.
  • -P — If the -R option is specified and a symbolic link is specified on the command line or encountered during the traversal of a file hierarchy, the chown command shall change the owner ID (and group ID, if specified) of the symbolic link if the system supports this operation. The chown command shall not follow the symbolic link to any other part of the file hierarchy.
  • -R — Descends directories recursively, changing the ownership for each file. When a symbolic link is encountered and the link points to a directory, the ownership of that directory is changed but the directory is not further transversed. If the -h, -H, -L or -P flags are not also specified, when a symbolic link is encountered and the link points to a directory, the group ownership of that directory is changed but the directory is not traversed further.

종료 상태

값 뜻
0 잘 실행했고 요청한 변경을 모두 했습니다.
0보다 큼 오류가 났습니다.
영어 원문

This command returns the following exit values:

  • 0 — The command executed successfully and all requested changes were made.
  • >0 — An error occurred.

보안

접근 제어

이 프로그램은 TCB(Trusted Computing Base)에 일반 사용자 프로그램으로 설치해야 합니다.

RBAC 사용자와 Trusted AIX 사용자는 주의하세요. 이 명령은 특권 작업을 할 수 있으며, 특권 작업은 특권 사용자만 할 수 있습니다. 이 명령에 걸린 특권과 권한(authorization) 목록은 lssecattr 명령이나 getcmdattr 하위 명령으로 봅니다. 이 문단은 6.1 문서에만 있습니다.

영어 원문

Access Control

This program should be installed as a normal user program in the Trusted Computing Base.

Attention RBAC users and Trusted AIX users: This command can perform privileged operations. Only privileged users can run privileged operations. For more information about authorizations and privileges, see Privileged Command Database in Security. For a list of privileges and the authorizations associated with this command, see the lssecattr command or the getcmdattr subcommand.

예제

  1. program.c 파일의 소유자를 바꿉니다. 이제 program.c의 사용자 접근 권한은 jim에게 적용되며, 소유자인 jim은 chmod로 다른 사용자의 접근을 허용하거나 막을 수 있습니다.
bash
chown jim program.c
  1. /tmp/src 디렉터리의 모든 파일의 소유자를 john, 그룹을 build로 바꿉니다.
bash
chown -R john:build /tmp/src
영어 원문
  1. To change the owner of the file program.c:
chown jim program.c

The user access permissions for program.c now apply to jim. As the owner, jim can use the chmod command to permit or deny other users access to program.c.

  1. To change the owner and group of all files in the directory /tmp/src to owner john and group build:
chown -R john:build /tmp/src

파일

파일 설명
/usr/bin/chown chown 명령입니다.
/etc/group 그룹 ID가 든 파일입니다.
/etc/passwd 사용자 ID가 든 파일입니다.

관련 명령어: chgrp, chmod

영어 원문
  • /usr/bin/chown — The chown command
  • /etc/group — File that contains group IDs
  • /etc/passwd — File that contains user IDs

Related reference:

  • chgrp Command
  • chmod Command

Related information:

  • chown command
  • File ownership and user groups
  • AIX Version 7.1 Security

리눅스(GNU)와 다른 점

항목 AIX 5.3·6.1 GNU chown
소유자.그룹 문서는 소유자:그룹만 설명 :과 함께 옛 형식 .도 받음
-R의 기본 링크 처리 디렉터리 링크의 소유권은 바꾸고 내려가지 않음 기본이 -P(따라가지 않음)

AIX 5.3·6.1 문서에는 -v, -c, --reference=파일, --from= 같은 GNU 플래그가 없습니다.