chgrp 명령어 (AIX 5.3·6.1)
https://archive.horanglab.com/posts/aix-cmd-chgrp
핵심 정리
- 파일이나 디렉터리의 그룹 소유권을 바꿉니다. 그룹 이름이나 숫자 그룹 ID를 씁니다.
-R은 디렉터리 아래까지 재귀적으로 바꿉니다.-f는 사용법 외 오류 메시지를 숨깁니다.- 심볼릭 링크는 기본으로 가리키는 대상을 바꾸고,
-h를 주면 링크 자체를 바꿉니다. -R과 함께-H(명령줄 링크만 따라감),-L(모든 디렉터리 링크 따라감),-P(따라가지 않음)를 씁니다.- 소유자까지 함께 바꾸려면
chown 소유자:그룹을 씁니다. - AIX 5.3과 6.1 문서의 내용이 같습니다.
| 항목 | 내용 |
|---|---|
| 버전 | AIX 5.3, AIX 6.1 (내용 같음, 6.1에 보안 절이 더해짐) |
| 원문 | IBM Commands Reference — 5.3 Volume 1, 6.1 Volume 1 |
| 파일 | /usr/bin/chgrp, /etc/group |
| 관련 명령어 | chown, groups, chmod |
목적
파일이나 디렉터리의 그룹 소유권을 바꿉니다.
영어 원문
Changes the group ownership of a file or directory.
구문
chgrp [ -f ] [ -h ] [ -R ] Group { File ... | Directory ... }
chgrp -R [ -f ] [ -H | -L | -P ] Group { File ... | Directory ... }
설명
chgrp 명령은 File이나 Directory 매개변수로 지정한 파일이나 디렉터리의 그룹을 Group 매개변수로 지정한 그룹으로 바꿉니다. Group 값은 그룹 데이터베이스의 그룹 이름이나 숫자 그룹 ID입니다.
심볼릭 링크를 만났을 때 -h나 -P 플래그가 없으면, 링크 자체가 아니라 링크가 가리키는 파일이나 디렉터리의 그룹 소유권을 바꿉니다.
-H, -L, -P는 서로 배타적이지만 둘 이상 지정해도 오류가 아닙니다. 마지막에 지정한 플래그가 동작을 정합니다.
-h를 지정하면 반대로 링크 자체의 그룹 소유권을 바꾸고 링크가 가리키는 대상은 바꾸지 않습니다. -h와 -R을 함께 지정하면 재귀적으로 내려가며, 심볼릭 링크를 만나면 링크 자체의 그룹 소유권을 바꿉니다.
영어 원문
The chgrp command changes the group of the file or directory specified by the File or Directory parameter to the group specified by the Group parameter. The value of the Group parameter can be a group name from the group database or a numeric group ID. When a symbolic link is encountered and you have not specified the -h or -P flags, the chgrp command changes the group ownership of the file or directory pointed to by the link and not the group ownership of the link itself.
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.
If you specify the -h flag, the chgrp command has the opposite effect and changes the group ownership of the link itself and not that of the file or directory pointed to by the link.
If you specify both the -h flag and the -R flag, the chgrp command descends the specified directories recursively, and when a symbolic link is encountered, the group ownership of the link itself is changed and not that of the file or directory pointed to by the link.
플래그
| 플래그 | 설명 |
|---|---|
-f |
사용법 메시지를 뺀 모든 오류 메시지를 숨깁니다. |
-h |
만난 심볼릭 링크 자체의 그룹 소유권을 바꾸고, 링크가 가리키는 파일이나 디렉터리는 바꾸지 않습니다. |
-H |
-R과 함께 쓸 때, 명령줄에 지정한 심볼릭 링크가 디렉터리를 가리키면 그 디렉터리와 그 아래 모든 파일의 그룹을 바꿉니다. |
-L |
-R과 함께 쓸 때, 명령줄에 지정했거나 탐색 중에 만난 심볼릭 링크가 디렉터리를 가리키면 그 디렉터리와 그 아래 모든 파일의 그룹을 바꿉니다. |
-P |
-R과 함께 쓸 때, 명령줄에 지정했거나 탐색 중에 만난 심볼릭 링크는 시스템이 지원하면 링크 자체의 그룹 ID를 바꿉니다. 링크를 따라 파일 계층의 다른 곳으로 가지 않습니다. |
-R |
디렉터리를 재귀적으로 내려가며 파일마다 지정한 그룹 ID를 설정합니다. 디렉터리를 가리키는 심볼릭 링크를 만나면 그 디렉터리의 그룹 소유권은 바꾸지만 더 내려가지 않습니다. |
영어 원문
-f— Suppresses all error messages except usage messages.-h— Changes the group ownership of an encountered symbolic link and not that of the file or directory pointed to by the symbolic link.-H— If the-Roption is specified and a symbolic link referencing a file of type directory is specified on the command line, chgrp shall change the group of the directory referenced by the symbolic link and all files in the file hierarchy below it.-L— If the-Roption 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, chgrp shall change the group of the directory referenced by the symbolic link and all files in the file hierarchy below it.-P— If the-Roption is specified and a symbolic link is specified on the command line or encountered during the traversal of a file hierarchy, chgrp shall change the group ID of the symbolic link if the system supports this operation. The chgrp utility shall not follow the symbolic link to any other part of the file hierarchy.-R— Descends directories recursively, setting the specified group ID for each file. 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 further traversed. If the-h,-H,-Lor-Pflags 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 — Successful completion.
>0— An error occurred.
보안
RBAC 사용자와 Trusted AIX 사용자는 주의하세요. 이 명령은 특권 작업을 할 수 있으며, 특권 작업은 특권 사용자만 할 수 있습니다. 이 명령에 걸린 특권과 권한(authorization) 목록은 lssecattr 명령이나 getcmdattr 하위 명령으로 봅니다. 이 절은 6.1 문서에만 있습니다.
영어 원문
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.
예제
proposals파일이나 디렉터리의 그룹 소유권을staff로 바꿉니다. 이제proposals의 그룹 접근 권한은staff그룹에 적용됩니다.
chgrp staff proposals
proposals디렉터리와 그 아래 모든 파일·하위 디렉터리의 그룹 소유권을staff로 바꿉니다.
chgrp -R staff proposals
영어 원문
- To change the group ownership of the file or directory named
proposalstostaff:
chgrp staff proposals
The group access permissions for proposals now apply to the staff group.
- To change the group ownership of the directory named
proposals,and of all the files and subdirectories under it, tostaff:
chgrp -R staff proposals
The group access permissions for proposals and for all the files and subdirectories under it now apply to the staff group.
파일
| 파일 | 설명 |
|---|---|
/usr/bin/chgrp |
chgrp 명령입니다. |
/etc/group |
알려진 모든 그룹을 정의하는 파일입니다. |
관련 명령어: chown, groups
영어 원문
- /usr/bin/chgrp — The chgrp command
- /etc/group — File that identifies all known groups
Related reference:
- chown Command
Related information:
- groups command
- chown command
- AIX Version 7.1 Security
- File ownership and user groups
리눅스(GNU)와 다른 점
| 항목 | AIX 5.3·6.1 | GNU chgrp |
|---|---|---|
-R의 기본 링크 처리 |
디렉터리 링크의 그룹은 바꾸고 내려가지 않음 | 기본이 -P(따라가지 않음) |
AIX 5.3·6.1 문서에는 -v, -c, --reference=파일 같은 GNU 플래그가 없습니다.