ÌáÉýLinuxϵͳÇå¾²ÐÔ£ºÓÅ»¯ºÍµ÷½âÎļþȨÏÞÉèÖÃ
ÔõÑùÓÅ»¯ºÍµ÷½âlinuxϵͳµÄÎļþȨÏÞÉèÖÃÒÔÌá¸ßÇå¾²ÐÔ
СÐò
ÔÚ½ñÌìµÄÊý×Öʱ´ú£¬Êý¾ÝÇå¾²ÊÇÖÁ¹ØÖ÷ÒªµÄ¡£¹ØÓÚLinuxϵͳÀ´Ëµ£¬ÎļþȨÏÞÉèÖÃÊÇÒ»¸öÒªº¦µÄÇå¾²²½·¥£¬Äܹ»ÓÐÓñ£»¤ÏµÍ³µÄÖ÷ÒªÊý¾Ý²»±»·ÇÊÚȨְԱ»á¼û»ò¸Ä¶¯¡£±¾ÎĽ«ÏÈÈÝÔõÑùÓÅ»¯ºÍµ÷½âlinuxϵͳµÄÎļþȨÏÞÉèÖÃÒÔÌá¸ßÇå¾²ÐÔ¡£
Ò»¡¢ÏàʶÎļþȨÏÞ
ÔÚ×îÏÈÓÅ»¯ºÍµ÷½âÎļþȨÏÞ֮ǰ£¬ÎÒÃÇÐèÒªÏàʶÎļþȨÏ޵Ļù±¾¿´·¨¡£ÔÚLinuxϵͳÖУ¬Ã¿¸öÎļþºÍĿ¼¶¼ÓÐÈý¸ö»ù±¾È¨ÏÞ£º¶ÁÈ¡£¨r£©¡¢Ð´È루w£©ºÍÖ´ÐУ¨x£©¡£ÕâЩȨÏÞ¿ÉÒÔ»®·ÖÔÚÓû§£¨owner£©¡¢Óû§×飨group£©ºÍÆäËûÓû§£¨others£©Ö®¼äÉèÖá£Í¨¹ý׼ȷÉèÖÃÕâЩȨÏÞ£¬ÎÒÃÇ¿ÉÒÔÈ·±£Ö»ÓÐÊÚȨµÄÓû§²Å»ª»á¼ûºÍÐÞ¸ÄÎļþ¡£
¶þ¡¢Ê¹ÓÃ×îСȨÏÞÔÔò
¡°×îСȨÏÞÔÔò¡±ÊÇÎļþȨÏÞÉèÖõÄÖ÷ÒªÔÔòÖ®Ò»¡£ÕâÒâζ×ÅÎÒÃÇÓ¦¸ÃΪÿ¸öÓû§ºÍÓû§×é·ÖÅÉ×îС»¯µÄȨÏÞ£¬ÒÔ±ÜÃâ²»ÐëÒªµÄÎļþ»á¼ûºÍÐ޸ġ£Æ¾Ö¤ÐèÇó£¬Ê¹ÓÃÕßÖ»ÄÜ»ñµÃËûÃÇÐèÒªµÄȨÏÞ£¬¶ø²»ÊǸøÓèËûÃÇËùÓÐȨÏÞ¡£Õâ¿ÉÒÔïÔÌDZÔÚ¹¥»÷ÕßµÄʱ»ú£¬²¢Ìá¸ßϵͳµÄÇå¾²ÐÔ¡£
Èý¡¢×ñÕÕ׼ȷµÄËùÓÐȨºÍ×éÉèÖÃ
׼ȷµÄËùÓÐȨºÍ×éÉèÖúÜÊÇÖ÷Òª£¬¿ÉÒÔÏÞÖÆÌض¨Óû§¶ÔÎļþµÄ»á¼ûȨÏÞ¡£Ã¿¸öÎļþºÍĿ¼¶¼ÓÐÒ»¸öËùÓÐÕߺÍÒ»¸öÊôÓÚÌض¨×éµÄ×顣ͨ¹ý׼ȷµÄÉèÖã¬ÎÒÃÇ¿ÉÒÔÈ·±£Ö»ÓÐËùÓÐÕߺÍ×é³ÉÔ±²ÅÓÐȨÁ¦»á¼ûÎļþ¡£
ÎÒÃÇ¿ÉÒÔʹÓÃchownÏÂÁî¸ü¸ÄÎļþ»òĿ¼µÄËùÓÐÕߣ¬ÀýÈ磺
chown user1 file1
µÇ¼ºó¸´ÖÆ
ÎÒÃÇ»¹¿ÉÒÔʹÓÃchgrpÏÂÁî¸ü¸ÄÎļþ»òĿ¼µÄ×飬ÀýÈ磺
chgrp group1 file1
µÇ¼ºó¸´ÖÆ
ËÄ¡¢×¼È·Ê¹ÓÃchmodÏÂÁî
chmodÏÂÁîÊǵ÷½âÎļþȨÏÞµÄÒªº¦ÏÂÁî¡£Ëü¿ÉÒÔÓÃÊý×Ö»ò·ûºÅÀ´ÌåÏÖȨÏÞÉèÖá£ÏÂÃæÊÇһЩ³£ÓõÄchmodÏÂÁîʾÀý£º
1) ʹÓÃÊý×ÖÌåÏÖȨÏÞ
chmod 644 file1 #ÉèÖÃÎļþËùÓÐÕßΪ¶Áд£¬×éºÍÆäËûÓû§ÎªÖ»¶Á chmod 755 dir1 #ÉèÖÃĿ¼ËùÓÐÕßΪ¶ÁдִÐУ¬×éºÍÆäËûÓû§Îª¶ÁÖ´ÐÐ
µÇ¼ºó¸´ÖÆ
2) ʹÓ÷ûºÅÌåÏÖȨÏÞ
chmod u=rw,g=r,o=r file1 #ÉèÖÃÎļþËùÓÐÕßΪ¶Áд£¬×éºÍÆäËûÓû§ÎªÖ»¶Á chmod u=rwx,g=rx,o=rx dir1 #ÉèÖÃĿ¼ËùÓÐÕßΪ¶ÁдִÐУ¬×éºÍÆäËûÓû§Îª¶ÁÖ´ÐÐ
µÇ¼ºó¸´ÖÆ
׼ȷʹÓÃchmodÏÂÁî¿ÉÒÔÈ·±£Ö»ÓÐÊÚȨÓû§Äܹ»Ö´ÐÐÌض¨µÄ²Ù×÷£¬Ìá¸ßϵͳµÄÇå¾²ÐÔ¡£
Î塢ʹÓÃACL£¨»á¼û¿ØÖÆÁÐ±í£©
³ýÁË»ù±¾µÄLinuxÎļþȨÏÞÉèÖÃÍ⣬ÎÒÃÇ»¹¿ÉÒÔʹÓÃACL£¨»á¼û¿ØÖÆÁÐ±í£©À´¸ü׼ȷµØ¿ØÖÆÎļþºÍĿ¼µÄ»á¼ûȨÏÞ¡£ACLÔÊÐíÎÒÃÇÔÚµ¥¸öÎļþ»òĿ¼ÉÏÉèÖöà¸öÓû§ºÍ×éµÄȨÏÞ¡£ÎÒÃÇ¿ÉÒÔʹÓÃsetfaclºÍgetfaclÏÂÁîÀ´Ìí¼Ó¡¢É¾³ýºÍÐÞ¸ÄACL¡£
ÀýÈ磬ÎÒÃÇ¿ÉÒÔʹÓÃsetfaclÏÂÁîΪÓû§1Ìí¼Ó¶ÁÈ¡ºÍдÈëȨÏÞ£º
setfacl -m u:user1:rw file1
µÇ¼ºó¸´ÖÆ
ʹÓÃgetfaclÏÂÁî¿ÉÒÔÉó²éÎļþ»òĿ¼µÄACLÉèÖãº
getfacl file1
µÇ¼ºó¸´ÖÆ
Áù¡¢°´ÆÚÉó²éȨÏÞÉèÖÃ
ÎļþȨÏÞÉèÖò»ÊÇÒ»´ÎÐÔµÄÊÂÇ飬¶øÊÇÐèÒª°´ÆÚÉó²éºÍµ÷½âµÄ¡£ÎÒÃÇÓ¦¸Ã°´ÆÚ¼ì²éÎļþºÍĿ¼µÄȨÏÞ£¬²¢É¾³ý²»ÔÙÐèÒªµÄÓû§ºÍ×éµÄ»á¼ûȨÏÞ¡£ÕâÑù¿ÉÒÔÈ·±£ÏµÍ³Ê¼ÖÕ¼á³ÖÔÚ×î¼ÑµÄÇ徲״̬Ï¡£
½áÂÛ
ͨ¹ýÓÅ»¯ºÍµ÷½âLinuxϵͳµÄÎļþȨÏÞÉèÖã¬ÎÒÃÇ¿ÉÒÔÓÐÓõØÌá¸ßϵͳµÄÇå¾²ÐÔ¡£Ê¹ÓÃ×îСȨÏÞÔÔò£¬×ñÕÕ׼ȷµÄËùÓÐȨºÍ×éÉèÖã¬×¼È·Ê¹ÓÃchmodÏÂÁîÒÔ¼°Ê¹ÓÃACL¾ÙÐиüϸÄåµÄȨÏÞ¿ØÖÆ£¬¿ÉÒÔ×ÊÖúÎÒÃDZÜÃâDZÔڵĹ¥»÷²¢±£»¤ÏµÍ³µÄÖ÷ÒªÊý¾Ý¡£Í¬Ê±£¬ÎÒÃÇÒ²Ó¦¸Ã°´ÆÚÉó²éȨÏÞÉèÖã¬ÒÔÈ·±£ÏµÍ³Ê¼ÖÕ¼á³ÖÔÚ×î¼ÑµÄÇ徲״̬Ï¡£
²Î¿¼×ÊÁÏ£º
LinuxȨÏÞÉèÖÃÖ¸ÄÏ£ºhttps://www.thegeekstuff.com/2010/04/unix-file-and-directory-permissions/
ʹÓÃACLÖÎÀíÎļþȨÏÞ£ºhttps://linux.die.net/man/1/setfacl
ÒÔÉϾÍÊÇÌáÉýLinuxϵͳÇå¾²ÐÔ£ºÓÅ»¯ºÍµ÷½âÎļþȨÏÞÉèÖõÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡