{"id":2499,"date":"2024-01-18T13:27:06","date_gmt":"2024-01-18T07:57:06","guid":{"rendered":"https:\/\/www.veeble.org\/kb\/?p=2499"},"modified":"2025-03-11T10:06:41","modified_gmt":"2025-03-11T04:36:41","slug":"modify-access-control-lists-acls-in-linux","status":"publish","type":"post","link":"https:\/\/www.veeble.com\/kb\/modify-access-control-lists-acls-in-linux\/","title":{"rendered":"How to Modify Access Control Lists (ACLs) in Linux"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2024\/01\/Talk-to-us-1-1-1.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"509\" src=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2024\/01\/Talk-to-us-1-1-1-1024x509.png\" alt=\"Access Control Lists\" class=\"wp-image-2507\" srcset=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/Talk-to-us-1-1-1-1024x509.png 1024w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/Talk-to-us-1-1-1-300x149.png 300w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/Talk-to-us-1-1-1-768x382.png 768w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/Talk-to-us-1-1-1-1536x763.png 1536w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/Talk-to-us-1-1-1-2048x1018.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Access Control Lists (ACLs) plays a crucial role in managing permissions and enhancing <a href=\"https:\/\/www.veeble.org\/kb\/managing-file-ownership-and-group-ownership-in-linux\/\" target=\"_blank\" rel=\"noreferrer noopener\">security in a Linux environment<\/a>. Access Control Lists (ACLs) is a powerful mechanism that enhances the traditional <a href=\"https:\/\/www.veeble.org\/kb\/linux-file-permissions\/\" target=\"_blank\" rel=\"noreferrer noopener\">file and directory permissions<\/a>. They provide a way to grant or deny specific permissions to users or groups beyond the basic<a href=\"https:\/\/www.veeble.org\/kb\/managing-file-ownership-and-group-ownership-in-linux\/\" target=\"_blank\" rel=\"noopener\"> owner-group-others<\/a> model. As a Linux enthusiast, exploring ACLs has enlightened me, offering granular control over file and directory access.<\/p>\n\n\n\n<p>Earlier, the only individuals requiring access to <a href=\"https:\/\/www.veeble.org\/kb\/creating-editing-file-via-ssh\/\" target=\"_blank\" rel=\"noreferrer noopener\">Linux filesystems<\/a> could be broadly categorized through the lens of traditional Linux file system permissions. In those simpler days, access control was delineated primarily among users, groups, and others, with read, write, and execute privileges serving as the limited spectrum of access rights. Finally, growing demands for precise file access led to a new era with Access Control Lists offering detailed permissions. ACLs enable precise permission customization, offering a sophisticated and adaptable approach to  managing access in Linux environments. This marked the beginning of a transformative journey from the simplicity of standard permissions to the versatility and precision offered by ACLs. However this added granularity empowers administrators to fine-tune access control, ensuring that specific users or groups have tailored permissions on a file or directory.<\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"modifying-specific-acl-entries\">Modifying Specific ACL Entries<\/h2>\n\n\n<p><strong>Syntax:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/For user;\nsetfacl   -m   u:username:permissions  &lt;file_or_directory&gt;\n\/\/For Group;\nsetfacl   -m   g:groupname:permissions  &lt;file_or_directory&gt;<\/code><\/pre>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>setfacl -m u:username:rw \/path\/to\/file<\/code><\/pre>\n\n\n<h5 class=\"wp-block-heading\" id=\"let-me-share-a-real-time-example-in-a-company-where-the-sales-and-finance-departments-often-collaborated-on-shared-data\"><strong>Let me share a real time example; In a company where the Sales and Finance departments often collaborated on shared data.<\/strong><\/h5>\n\n\n<p>In the shared directory \/company\/shared, the Sales and Finance departments needed different levels of access to files. The Sales team required read and write access for collaboration, while the Finance team needed read-only access to maintain data integrity.<\/p>\n\n\n\n<p>Before configuring ACLs, make sure to install the <a href=\"https:\/\/launchpad.net\/ubuntu\/+source\/acl\" target=\"_blank\" rel=\"noreferrer noopener\"><code>acl<\/code> package<\/a> using your package manager:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@ervintest ~]# yum install -y acl  <\/code><\/pre>\n\n\n\n<p>Set Default ACLs:\n<br>Grant read and write permissions to Sales group, read-only to Finance group\n<br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@ervintest ~]# setfacl -m g:sales:rwx \/company\/shared\n&#91;root@ervintest ~]# setfacl -m g:finance:rx \/company\/shared\n<\/code><\/pre>\n\n\n\n<p>Sales should have read and write permission to a file sales_report.xlsx in shared directory. Then finance should have read only permission for&nbsp; financial_summary.pdf in the shared directory.<\/p>\n\n\n\n<p>For this specific files, customize ACLs based on department needs:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@ervintest ~]# setfacl -m g:sales:rw \/company\/shared\/sales_report.xlsx\n&#91;root@ervintest ~]# setfacl -m g:finance:r \/company\/shared\/financial_summary.pdf\n<\/code><\/pre>\n\n\n\n<p>To confirm the intended ACLs<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@ervintest ~]# getfacl \/company\/shared<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-18-121935.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"870\" height=\"326\" src=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-18-121935.png\" alt=\"\" class=\"wp-image-2512\" srcset=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-18-121935.png 870w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-18-121935-300x112.png 300w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-18-121935-768x288.png 768w\" sizes=\"auto, (max-width: 870px) 100vw, 870px\" \/><\/a><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@ervintest ~]# getfacl \/company\/shared\/sales_report.xlsx<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2024\/01\/sales-1.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"973\" height=\"270\" src=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2024\/01\/sales-1.png\" alt=\"\" class=\"wp-image-2510\" srcset=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/sales-1.png 973w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/sales-1-300x83.png 300w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/sales-1-768x213.png 768w\" sizes=\"auto, (max-width: 973px) 100vw, 973px\" \/><\/a><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@ervintest ~]# getfacl \/company\/shared\/financial_summary.pdf<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2024\/01\/finance-1.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"972\" height=\"274\" src=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2024\/01\/finance-1.png\" alt=\"\" class=\"wp-image-2511\" srcset=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/finance-1.png 972w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/finance-1-300x85.png 300w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/finance-1-768x216.png 768w\" sizes=\"auto, (max-width: 972px) 100vw, 972px\" \/><\/a><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Sales has read, write and execute access to the shared directory and&nbsp; read, write access to specific file(sales_report.xlsx)<\/li>\n\n\n\n<li>Finance has read and execute access to the entire directory, and read only access to financial_summary.pdf&nbsp; ensuring data integrity.<\/li>\n<\/ul>\n\n\n\n<p>Certainly! Let&#8217;s consider another scenario where a user from the Sales group needs to set an ACL for a specific file within the shared directory \/company\/shared.<\/p>\n\n\n\n<p>Suppose&nbsp; the user&#8217;s name is &#8220;alice&#8221; needs read and write permissions for a file named sales_presentation.ppt:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@ervintest ~]# setfacl -m u:alice:rw \/company\/shared\/sales_presentation.ppt<\/code><\/pre>\n\n\n\n<p>To confirm the intended ACLs<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@ervintest ~]# getfacl \/company\/shared\/sales_presentation.ppt<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2024\/01\/sales.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"973\" height=\"270\" src=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2024\/01\/sales.png\" alt=\"\" class=\"wp-image-2508\" srcset=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/sales.png 973w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/sales-300x83.png 300w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/sales-768x213.png 768w\" sizes=\"auto, (max-width: 973px) 100vw, 973px\" \/><\/a><\/figure>\n\n\n\n<p>In this collaborative environment, ACLs proved invaluable in meeting the distinct needs of Sales and Finance. This fine-grained control ensures efficient collaboration while maintaining the security and integrity of sensitive financial data. Integrating ACLs into your system&#8217;s access management toolkit enhances your ability to tailor permissions, making it a valuable asset in diverse and collaborative work environments.<\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"removing-specific-acl-entries\">Removing Specific ACL Entries<\/h2>\n\n\n<ul class=\"wp-block-list\">\n<li>To remove an ACL entry, you can use the <code>-x<\/code> option with the <code>setfacl<\/code> command. In the previous example, if you want to remove the ACL entry that grants read, write, and execute permissions to the &#8220;sales&#8221; group on <code>\/company\/shared<\/code>, you can use the following command:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@ervintest ~]# setfacl -x g:sales \/company\/shared<\/code><\/pre>\n\n\n\n<p>This command removes the specified ACL entry for the &#8220;sales&#8221; group on the <code>\/company\/shared<\/code> directory. After running this command, if you check the ACL of the directory using <code>getfacl \/company\/shared<\/code>, you should see the updated ACL without the &#8220;sales&#8221; group entry:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Certainly! If you want to remove all ACL entries for the &#8220;sales&#8221; group on the <code>\/company\/shared<\/code> directory, you can use the <code>-b<\/code> option with the <code>setfacl<\/code> command. Here&#8217;s the command:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@ervintest ~]# setfacl -b \/company\/shared\n<\/code><\/pre>\n\n\n\n<p>This command clears all ACL entries for the specified file or directory, effectively removing any ACL settings. After running this command, if you check the ACL of the directory using <code>getfacl \/company\/shared<\/code>, you should see that there are no ACL entries:<\/p>\n\n\n\n<div style=\"height:35px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-uagb-call-to-action uagb-block-a7bf08e3 wp-block-button\"><div class=\"uagb-cta__wrap\"><h3 class=\"uagb-cta__title\">Take Control with cPanel<\/h3><p class=\"uagb-cta__desc\">Manage every aspect of your website with our intuitive cPanel. From email setup to file management, enjoy complete control. Experience reliable hosting with robust features.<\/p><\/div><div class=\"uagb-cta__buttons\"><a href=\"https:\/\/www.veeble.com\/in\/cpanel-hosting\/\" class=\"uagb-cta__button-link-wrapper wp-block-button__link\" target=\"_blank\" rel=\"noopener noreferrer\">Choose Your Plan<svg xmlns=\"https:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\"><path d=\"M504.3 273.6l-112.1 104c-6.992 6.484-17.18 8.218-25.94 4.406c-8.758-3.812-14.42-12.45-14.42-21.1L351.9 288H32C14.33 288 .0002 273.7 .0002 255.1S14.33 224 32 224h319.9l0-72c0-9.547 5.66-18.19 14.42-22c8.754-3.809 18.95-2.075 25.94 4.41l112.1 104C514.6 247.9 514.6 264.1 504.3 273.6z\"><\/path><\/svg><\/a><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Access Control Lists (ACLs) plays a crucial role in managing permissions and enhancing security in a Linux environment. Access Control Lists (ACLs) is a [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":2507,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[5,9],"tags":[],"class_list":["post-2499","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-firewallsecurity"],"uagb_featured_image_src":{"full":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/Talk-to-us-1-1-1.png",2888,1435,false],"thumbnail":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/Talk-to-us-1-1-1-150x150.png",150,150,true],"medium":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/Talk-to-us-1-1-1-300x149.png",300,149,true],"medium_large":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/Talk-to-us-1-1-1-768x382.png",768,382,true],"large":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/Talk-to-us-1-1-1-1024x509.png",1024,509,true],"1536x1536":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/Talk-to-us-1-1-1-1536x763.png",1536,763,true],"2048x2048":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/01\/Talk-to-us-1-1-1-2048x1018.png",2048,1018,true]},"uagb_author_info":{"display_name":"Nayana Nair","author_link":"https:\/\/www.veeble.com\/kb\/author\/nayana\/"},"uagb_comment_info":0,"uagb_excerpt":"Access Control Lists (ACLs) plays a crucial role in managing permissions and enhancing security in a Linux environment. Access Control Lists (ACLs) is a [&hellip;]","_links":{"self":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts\/2499","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/comments?post=2499"}],"version-history":[{"count":18,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts\/2499\/revisions"}],"predecessor-version":[{"id":7985,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts\/2499\/revisions\/7985"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/media\/2507"}],"wp:attachment":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/media?parent=2499"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/categories?post=2499"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/tags?post=2499"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}