소프트웨어, 운영체제/Linux

Linux_chgrp(change group)

OHSAYU 2024. 1. 15. 04:38

■ chgrp(change group) : 파일 시스템 오브젝트에 연결된 그룹을 변경하는 명령어. 그룹을 변경하려면 슈퍼유저(root) 권한이거나 파일 소유자여야한다. 또한 현재 사용자는 그룹이 지정한 그룹 프로파일에 대한 *USE 권한이 있어야 한다. 

■ 구조

chgrp [options] group sample [sample2...]

■ 옵션

● -R : 재귀적으로 파일들과 디렉터리들의 모드들을 바꾼다.

※ -R 이외에는 거의 사용되지 않아 생략

■ 예시

sample 디렉터리의 그룹을  user1으로 변경

[root@TEST test]# ls -l
total 0
drwxr-xr-x. 2 root root 6 Jan 15 03:57 sample
[root@TEST test]# chgrp user1 sample/ ############################## sol
[root@TEST test]# ls -l
total 0
drwxr-xr-x. 2 root user1 6 Jan 15 03:57 sample

 

 sample 디렉터리 아래의 모든 파일 및 서브디렉터리의 그룹을  user1으로 변경

[root@TEST test]# ls -l
total 0
drwxr-xr-x. 2 root root 6 Jan 15 03:57 sample
[root@TEST test]# chgrp -R user1 sample/ ############################## sol
[root@TEST test]# ls -l
total 0
drwxr-xr-x. 2 root user1 6 Jan 15 03:57 sample

 

현재 디렉터리 아래의 모든 파일 및 서브디렉터리의 그룹을  user2으로 변경

[root@TEST test]# ls -l
total 0
drwxr-xr-x. 2 root user1 21 Jan 15 04:00 sample
-rw-r--r--. 1 root root   0 Jan 15 04:36 sample2
[root@TEST test]# chgrp user2 * ################################ sol 
[root@TEST test]# ls -l
total 0
drwxr-xr-x. 2 root user2 21 Jan 15 04:00 sample
-rw-r--r--. 1 root user2  0 Jan 15 04:36 sample2

 

 

출처 : https://ko.wikipedia.org/wiki/Chgrp

 

chgrp - 위키백과, 우리 모두의 백과사전

위키백과, 우리 모두의 백과사전.

ko.wikipedia.org

출처 : https://www.ibm.com/docs/ko/i/7.3?topic=directories-chgrp

 

chgrp - 파일 그룹 소유권 변경

요약 chgrp [-R [ -H | -L | -P ]] [ -h ] group file ... 설명 chgrp를 사용하여 파일의 그룹을 그룹이 지정한 그룹 ID 또는 프로파일로 설정할 수 있습니다. 그룹 ID를 변경하려면 다음 권한 중 하나가 있어야

www.ibm.com