본문 바로가기

공부/리눅스

ACL (Access Control List)

반응형
setfacl
Usage: setfacl [-bkndRLP] { -m|-M|-x|-X ... } file ...

주요옵션
-m : acl 설정
-x : acl 삭제
-b : 모든 acl 삭제
--mask : mask 재설정
-R : 하위디렉토리까지 포함.

[root@centos1 acl]# setfacl -m u:user1:rwx a.txt
[root@centos1 acl]# ls -l a.txt
-rw-rwxr--+ 1 root root 6  8월  5 08:50 a.txt ; acl 설정이 된 경우 퍼미션 맨끝에 '+' 문자가 보인다.
[root@centos1 acl]# getfacl a.txt  ; acl 설정확인을 할 수 있다.
# file: a.txt
# owner: root
# group: root
user::rw-
user:user1:rwx
group::r--
mask::rwx
other::r--

[root@centos1 acl]# setfacl -x u:user1 a.txt ; acl 설정중 user1 권한 삭제
[root@centos1 acl]# setfacl -b a.txt ; 모든 acl 설정 삭제.

[root@centos1 acl]# setfacl -m u:user1:r-x,u:user2:rw a.txt
[root@centos1 acl]# ls -l a.txt
-rw-rwxr--+ 1 root root 6  8월  5 08:50 a.txt ; 파일의 그룹권한이 바뀐다.
[root@centos1 acl]#

[root@centos1 acl]# getfacl a.txt
# file: a.txt
# owner: root
# group: root
user::rw-
user:user1:r-x
user:user2:rw-
group::r--
mask::rwx          ; mask 값은 파일그룹권한과 같다.
other::r--

[root@centos1 acl]#
[root@centos1 acl]# chmod 755 a.txt ; acl 설정이 된 파일의 퍼미션을 바꾸면...
[root@centos1 acl]# ls -l a.txt
-rwxr-xr-x+ 1 root root 6  8월  5 08:50 a.txt
[root@centos1 acl]# getfacl a.txt
# file: a.txt
# owner: root
# group: root
user::rwx
user:user1:r-x
user:user2:rw-                  #effective:r--    ; effective 권한이 실제권한이다.
group::r--                                              effective 권한은 설정권한과 umask 값의 교집합으로 결정된다.
mask::r-x                 
other::r-x

[root@centos1 acl]# setfacl -b a.txt
[root@centos1 acl]# setfacl -m u:user1:rwx,g:staff:r-x,g:root:rwx,m:r-x a.txt
[root@centos1 acl]# getfacl a.txt
# file: a.txt
# owner: root
# group: root
user::rwx
user:user1:rwx                  #effective:r-x
group::r--
group:root:rwx                  #effective:r-x
group:staff:r-x
mask::r-x
other::r-x
[root@centos1 acl]#

[root@centos1 acl]# mkdir d1
[root@centos1 acl]# setfacl -m default:u:user1:rw-,g:staff:rwx d1 
default 옵션을 주면 d1 디렉토리내의 파일과 디렉토리는 acl권한이
자동으로 설정된다.
[root@centos1 acl]# getfacl d1
# file: d1
# owner: root
# group: root
user::rwx
group::r-x
group:staff:rwx
mask::rwx
other::r-x
default:user::rwx
default:user:user1:rw-
default:group::r-x
default:mask::rwx
default:other::r-x
[root@centos1 acl]#

[root@centos1 d1]# echo "hello" > a.txt
[root@centos1 d1]# ls -l
합계 8
-rw-rw-r--+ 1 root root 6  8월  5 09:15 a.txt
[root@centos1 d1]# getfacl a.txt
# file: a.txt
# owner: root
# group: root
user::rw-
user:user1:rw-
group::r-x                      #effective:r--
mask::rw-
other::r--

[root@centos1 d1]#

반응형