Ö¸ÄÏ£ºÊ¹ÓÃLinux ACL±£»¤ÄúµÄÎļþºÍĿ¼
ÔÚLinux²Ù×÷ϵͳÖУ¬ACL£¨Access Control List£©ÊÇÒ»ÖÖºÜÊÇÇ¿Ê¢µÄ¹¤¾ß£¬¿ÉÒÔÓÃÀ´¸üϸÄåµØ¿ØÖƶÔÎļþºÍĿ¼µÄ»á¼ûȨÏÞ¡£Í¨¹ýACL£¬Óû§¿ÉÒÔΪÌض¨µÄÓû§»òÓû§×éÉèÖÃÌض¨µÄȨÏÞ£¬¶ø²»µ«½ö¾ÖÏÞÓڹŰåµÄÓû§ºÍ×éµÄ¶Á¡¢Ð´¡¢Ö´ÐÐȨÏÞ¡£±¾ÎĽ«ÎªÄúÏÈÈÝÔõÑùʹÓÃACLÀ´±£»¤ÄúµÄÎļþºÍĿ¼£¬Í¬Ê±ÌṩÏêϸµÄ´úÂëʾÀý¹©²Î¿¼¡£
ʲôÊÇACL£¿
ÔڹŰåµÄLinuxȨÏÞÖÎÀíÖУ¬ÎļþºÍĿ¼µÄȨÏÞÓÉËùÓÐÕß¡¢ËùÊô×éºÍÆäËûÓû§Èý¸öÉí·ÝÀ´¾öÒ顣Ȼ¶ø£¬ÔÚijЩÇéÐÎÏ£¬ÕâÖÖ´ÖÁ£¶ÈµÄȨÏÞ¿ØÖÆ¿ÉÄÜÎÞ·¨Öª×ãÓû§µÄÐèÇó¡£Õâʱ¼ä¾Í¿ÉÒÔ½èÖúACLÀ´×ö¸üÏ꾡µÄȨÏÞÖÎÀí¡£
ACLÔÊÐíÓû§ÎªÌض¨Óû§»òÓû§×éÉèÖÃÌض¨È¨ÏÞ£¬°üÀ¨¶ÁÈ¡¡¢Ð´Èë¡¢Ö´Ðеȡ£Í¨¹ýACL£¬Óû§¿ÉÒÔ¸ü׼ȷµØ¿ØÖƶÔÎļþºÍĿ¼µÄ»á¼ûȨÏÞ£¬Ìá¸ßÎļþµÄÇå¾²ÐÔ¡£
×°ÖÃACL¹¤¾ß
´ó´ó¶¼Linux¿¯Ðа涼×Ô´øÁËACL¹¤¾ß£¬µ«ÈôÊÇÄúµÄϵͳûÓÐ×°Ö㬿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´×°Öãº
sudo apt-get install acl # ¹ØÓÚDebian/Ubuntuϵͳ sudo yum install acl # ¹ØÓÚCentOS/RHELϵͳ
µÇ¼ºó¸´ÖÆ
×°ÖÃÍê³Éºó£¬Äú¾Í¿ÉÒÔ×îÏÈʹÓÃACL¶ÔÎļþºÍĿ¼¾ÙÐÐȨÏÞ¿ØÖÆÁË¡£
ÉèÖÃACLʾÀý
ΪÌض¨Óû§ÉèÖÃACL
¼ÙÉèÎÒÃÇÒªÉèÖÃÒ»¸öÃûΪexample.txtµÄÎļþ£¬Ö»ÓÐuser1Óû§²Å»ª¶ÁдÕâ¸öÎļþ£¬ÆäËûÓû§Ö»ÄܶÁÈ¡¡£Ê×ÏÈ£¬ÎÒÃÇ¿ÉÒÔʹÓÃsetfaclÏÂÁîÀ´ÉèÖÃACL£º
setfacl -m u:user1:rw example.txt
µÇ¼ºó¸´ÖÆ
ÕâÌõÏÂÁîÌåÏÖΪexample.txtÎļþµÄÓû§user1ÉèÖöÁдȨÏÞ¡£
ΪÌض¨Óû§×éÉèÖÃACL
ÈôÊÇÎÒÃÇÏëÈÃij¸öÓû§×éÓµÓжÔÒ»¸öĿ¼µÄÍêÈ«»á¼ûȨÏÞ£¬¿ÉÒÔʹÓÃÈçÏÂÏÂÁ
setfacl -m g:group1:rwx /path/to/directory
µÇ¼ºó¸´ÖÆ
ÕâÌõÏÂÁîÌåÏÖΪ/path/to/directoryĿ¼µÄÓû§×égroup1ÉèÖöÁ¡¢Ð´¡¢Ö´ÐÐȨÏÞ¡£
Éó²éACL
ÒªÉó²éÌض¨Îļþ»òĿ¼µÄACLÉèÖ㬿ÉÒÔʹÓÃgetfaclÏÂÁ
getfacl example.txt
µÇ¼ºó¸´ÖÆ
Õ⽫ÏÔʾ³öexample.txtÎļþµÄACLÐÅÏ¢£¬°üÀ¨Óû§ºÍÓû§×éµÄȨÏÞ¡£
ACLµÄ³£ÓòÙ×÷
³ýÁËÉÏÊöʾÆÆÀý£¬ACL»¹¾ßÓÐÐí¶àÆäËû³£ÓòÙ×÷£¬ºÃ±ÈÐÞ¸ÄACL¡¢ÒƳýACL¡¢Ó¦ÓÃACLµ½×ÓĿ¼µÈ¡£ÒÔÏÂÊÇһЩ³£ÓõÄACL²Ù×÷£º
ÐÞ¸ÄACL
setfacl -m u:user1:rx example.txt # ΪÓû§user1Ìí¼Ó¶ÁÈ¡ºÍÖ´ÐÐȨÏÞ
µÇ¼ºó¸´ÖÆ
ÒƳýACL
setfacl -x u:user1 example.txt # ÒƳýÓû§user1¶Ôexample.txtµÄACLÉèÖÃ
µÇ¼ºó¸´ÖÆ
Ó¦ÓÃACLµ½×ÓĿ¼
setfacl -R -m g:group1:rwx /path/to/directory # µÝ¹éÓ¦ÓÃACLµ½Ä¿Â¼¼°Æä×ÓĿ¼
µÇ¼ºó¸´ÖÆ
×ܽá
ͨ¹ýʹÓÃACL£¬Äú¿ÉÒÔÔ½·¢ÎÞаµØ¿ØÖÆÎļþºÍĿ¼µÄ»á¼ûȨÏÞ£¬Ìá¸ßϵͳµÄÇå¾²ÐÔ¡£±¾ÎÄÏÈÈÝÁËACLµÄ»ù±¾¿´·¨¡¢×°ÖÃÒªÁìÒÔ¼°³£ÓõÄACL²Ù×÷£¬Ï£ÍûÄÜ×ÊÖúÄú¸üºÃµØ±£»¤ÄúµÄÎļþºÍĿ¼¡£
ÔÚLinuxϵͳÖУ¬ACLÊÇÒ»¸öºÜÊÇÇ¿Ê¢µÄ¹¤¾ß£¬¿ÉÒÔ×ÊÖúÓû§ÊµÏÖ¸üÏ꾡µÄȨÏÞÖÎÀí¡£ÈôÊÇÄúÓÐÐèÒª¶ÔÎļþȨÏÞ¾ÙÐиü׼ȷ¿ØÖƵÄÇéÐΣ¬ÎÞ·ÁʵÑéʹÓÃACLÀ´µÖ´ïÄúµÄÄ¿µÄ¡£
ÒÔÉϾÍÊÇÖ¸ÄÏ£ºÊ¹ÓÃLinux ACL±£»¤ÄúµÄÎļþºÍĿ¼µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡