LINUX ACL 설정을 확인해 보자 (linux5,6)
ACL (Access Control List )
파티션에 있는 디렉토리나 파일에 특정 사용자, 그룹, 기타 권한을 넣어주는 기능
# setfacl 옵션
setfacl 2.2.39 -- set file access control lists
Usage: setfacl [-bkndRLP] { -m|-M|-x|-X ... } file ...
-m, --modify=acl modify the current ACL(s) of file(s)
-> acl 권한 설정을 추가한다.
-M, --modify-file=file read ACL entries to modify from file
-x, --remove=acl remove entries from the ACL(s) of file(s)
-> acl 권한 설정을 삭제한다.
-X, --remove-file=file read ACL entries to remove from file
-b, --remove-all remove all extended ACL entries
-> acl 모든 권한 설정을 삭제한다.
-k, --remove-default remove the default ACL
--set=acl set the ACL of file(s), replacing the current ACL
--set-file=file read ACL entries to set from file
--mask do recalculate the effective rights mask
-n, --no-mask don't recalculate the effective rights mask
-d, --default operations apply to the default ACL
-> 하위 경로 파일/디렉토리가 만들어 질 경우 acl 설정
-R, --recursive recurse into subdirectories
-> 하위 경로 파일/디렉토리에도 설정.
-L, --logical logical walk, follow symbolic links
-P, --physical physical walk, do not follow symbolic links
--restore=file restore ACLs (inverse of `getfacl -R')
--test test mode (ACLs are not modified)
-v, --version print version and exit
-h, --help this help text
# setfacl
# setfacl -m <rules> <file>
-> acl 기능을 추가 및 수정한다.
# setfacl -x <rules> <file>
-> acl 기능을 삭제한다.
-> x옵션 후 아무런 <rules>을 사용하지 않을 경우 모든 권한이 삭제된다.
<rules>
d:
-> default 설정으로 폴더에 적용하여서 폴더 안에서 생성된 파일이나 폴더는 ACL 퍼미션값을 따라간다.
u:<UID, 계정명>:rwx
-> 유저에게 권한 설정
g:<GID, 그룹명>:rwx
-> 그룹에게 권한 설정
m:rwx
-> mask 권한 설정
o:rwx
-> other 기타소유자에게 권한 설정
<사용 명령어>
# setfacl -m u:500:rwx /test
-> /test 폴더에 500 UID의 유저에게 rwx권한을 준다.
# setfacl -m u:dongwook:rwx /test
-> /test 폴더에 dongwook 유저에게 rwx권한을 준다.
# setfacl -m d:u:dongwook:rwx /test
-> /test 폴더에 dongwook 유저에게 rwx권한을 주며, /test 폴더 아래 생성되는 폴더/파일은 동일한 퍼미션값을 준다.
# getfacl 옵션
getfacl 2.2.39 -- get file access control lists
Usage: getfacl [-dRLPvh] file ...
--access display the file access control list only
-d, --default display the default access control list only
--omit-header do not display the comment header
--all-effective print all effective rights
--no-effective print no effective rights
--skip-base skip files that only have the base entries
-R, --recursive recurse into subdirectories
-L, --logical logical walk, follow symbolic links
-P --physical physical walk, do not follow symbolic links
--tabular use tabular output format
--numeric print numeric user/group identifiers
--absolute-names don't strip leading '/' in pathnames
-v, --version print version and exit
-h, --help this help text
# getfacl
getfacl은 setfacl으로 권한 설정한 내용을 보는 명령어 이다.
# getfacl test/
file: test
owner: root
group: root
user::rwx
group::r-x
other::r-x
acl 권한 그대로 복사
1. mv으로 파일이나 폴더를 이동 할경우 acl 옵션이 따라간다.
2. cp으로 파일이나 폴더를 복사 할경우 acl 옵션이 따라가지 않는다.
3. cp -p 으로 파일이나 폴더를 복사 할경우 acl 옵션이 따라간다.
acl을 사용하려면
acl을 사용하려면 파티션에서 acl 기능이 들어가 있어야한다.
1. tune2fs 으로 현재 파티션에 acl 기능이 들어가 있는지 확인.
# tune2fs -l /dev/sda1
tune2fs 1.39 (29-May-2006)
Filesystem volume name: /boot
Last mounted on: <not available>
Filesystem UUID: da819e23-2f6d-4c35-81b0-5c5ff37f854f
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery sparse_super
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 26104
Block count: 104388
Reserved block count: 5219
Free blocks: 78779
Free inodes: 26064
First block: 1
Block size: 1024
Fragment size: 1024
Reserved GDT blocks: 256
Blocks per group: 8192
Fragments per group: 8192
Inodes per group: 2008
Inode blocks per group: 251
Filesystem created: Mon Jun 24 23:00:39 2013
Last mount time: Mon Aug 26 22:23:13 2013
Last write time: Mon Aug 26 22:23:13 2013
Mount count: 28
Maximum mount count: -1
Last checked: Mon Jun 24 23:00:39 2013
Check interval: 0 (<none>)
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 128
Journal inode: 8
Default directory hash: tea
Directory Hash Seed: f1306cd0-aa95-4343-aed9-77888bde3787
Journal backup: inode blocks
2. 파티션에 acl 옵션이 안들어가 있을 경우 추가 설정.
# tune2fs -o acl,user_xattr <디바이스명>
-> 파티션에 영구적으로 acl 옵션을 설정
# vi /etc/fstab
-> 해당 디바이스 마운트 옵션 default에 acl을 추가.
파티션에 있는 디렉토리나 파일에 특정 사용자, 그룹, 기타 권한을 넣어주는 기능
# setfacl 옵션
setfacl 2.2.39 -- set file access control lists
Usage: setfacl [-bkndRLP] { -m|-M|-x|-X ... } file ...
-m, --modify=acl modify the current ACL(s) of file(s)
-> acl 권한 설정을 추가한다.
-M, --modify-file=file read ACL entries to modify from file
-x, --remove=acl remove entries from the ACL(s) of file(s)
-> acl 권한 설정을 삭제한다.
-X, --remove-file=file read ACL entries to remove from file
-b, --remove-all remove all extended ACL entries
-> acl 모든 권한 설정을 삭제한다.
-k, --remove-default remove the default ACL
--set=acl set the ACL of file(s), replacing the current ACL
--set-file=file read ACL entries to set from file
--mask do recalculate the effective rights mask
-n, --no-mask don't recalculate the effective rights mask
-d, --default operations apply to the default ACL
-> 하위 경로 파일/디렉토리가 만들어 질 경우 acl 설정
-R, --recursive recurse into subdirectories
-> 하위 경로 파일/디렉토리에도 설정.
-L, --logical logical walk, follow symbolic links
-P, --physical physical walk, do not follow symbolic links
--restore=file restore ACLs (inverse of `getfacl -R')
--test test mode (ACLs are not modified)
-v, --version print version and exit
-h, --help this help text
# setfacl
# setfacl -m <rules> <file>
-> acl 기능을 추가 및 수정한다.
# setfacl -x <rules> <file>
-> acl 기능을 삭제한다.
-> x옵션 후 아무런 <rules>을 사용하지 않을 경우 모든 권한이 삭제된다.
<rules>
d:
-> default 설정으로 폴더에 적용하여서 폴더 안에서 생성된 파일이나 폴더는 ACL 퍼미션값을 따라간다.
u:<UID, 계정명>:rwx
-> 유저에게 권한 설정
g:<GID, 그룹명>:rwx
-> 그룹에게 권한 설정
m:rwx
-> mask 권한 설정
o:rwx
-> other 기타소유자에게 권한 설정
<사용 명령어>
# setfacl -m u:500:rwx /test
-> /test 폴더에 500 UID의 유저에게 rwx권한을 준다.
# setfacl -m u:dongwook:rwx /test
-> /test 폴더에 dongwook 유저에게 rwx권한을 준다.
# setfacl -m d:u:dongwook:rwx /test
-> /test 폴더에 dongwook 유저에게 rwx권한을 주며, /test 폴더 아래 생성되는 폴더/파일은 동일한 퍼미션값을 준다.
# getfacl 옵션
getfacl 2.2.39 -- get file access control lists
Usage: getfacl [-dRLPvh] file ...
--access display the file access control list only
-d, --default display the default access control list only
--omit-header do not display the comment header
--all-effective print all effective rights
--no-effective print no effective rights
--skip-base skip files that only have the base entries
-R, --recursive recurse into subdirectories
-L, --logical logical walk, follow symbolic links
-P --physical physical walk, do not follow symbolic links
--tabular use tabular output format
--numeric print numeric user/group identifiers
--absolute-names don't strip leading '/' in pathnames
-v, --version print version and exit
-h, --help this help text
# getfacl
getfacl은 setfacl으로 권한 설정한 내용을 보는 명령어 이다.
# getfacl test/
file: test
owner: root
group: root
user::rwx
group::r-x
other::r-x
acl 권한 그대로 복사
1. mv으로 파일이나 폴더를 이동 할경우 acl 옵션이 따라간다.
2. cp으로 파일이나 폴더를 복사 할경우 acl 옵션이 따라가지 않는다.
3. cp -p 으로 파일이나 폴더를 복사 할경우 acl 옵션이 따라간다.
acl을 사용하려면
acl을 사용하려면 파티션에서 acl 기능이 들어가 있어야한다.
1. tune2fs 으로 현재 파티션에 acl 기능이 들어가 있는지 확인.
# tune2fs -l /dev/sda1
tune2fs 1.39 (29-May-2006)
Filesystem volume name: /boot
Last mounted on: <not available>
Filesystem UUID: da819e23-2f6d-4c35-81b0-5c5ff37f854f
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery sparse_super
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 26104
Block count: 104388
Reserved block count: 5219
Free blocks: 78779
Free inodes: 26064
First block: 1
Block size: 1024
Fragment size: 1024
Reserved GDT blocks: 256
Blocks per group: 8192
Fragments per group: 8192
Inodes per group: 2008
Inode blocks per group: 251
Filesystem created: Mon Jun 24 23:00:39 2013
Last mount time: Mon Aug 26 22:23:13 2013
Last write time: Mon Aug 26 22:23:13 2013
Mount count: 28
Maximum mount count: -1
Last checked: Mon Jun 24 23:00:39 2013
Check interval: 0 (<none>)
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 128
Journal inode: 8
Default directory hash: tea
Directory Hash Seed: f1306cd0-aa95-4343-aed9-77888bde3787
Journal backup: inode blocks
2. 파티션에 acl 옵션이 안들어가 있을 경우 추가 설정.
# tune2fs -o acl,user_xattr <디바이스명>
-> 파티션에 영구적으로 acl 옵션을 설정
# vi /etc/fstab
-> 해당 디바이스 마운트 옵션 default에 acl을 추가.
댓글
댓글 쓰기