Skip to main content

Command Palette

Search for a command to run...

๐ŸŒ Access Control Lists (ACLs) in ๐Ÿง Linux: Managing File Permissions

Updated
โ€ข2 min read
๐ŸŒ Access Control Lists (ACLs) in ๐Ÿง Linux: Managing File Permissions

๐Ÿ‘‰ Quick Intro ๐Ÿ”ฅ

  • Access control list (ACL) provides an additional, more flexible permission mechanism for file systems.

  • Using ACL we can give file or directory permissions to particular user or group

  • Think of a scenario, In a library certain rooms are for specific groups. But, if you want to give a friend access to a room without them joining the group, think of Access Control Lists (ACLs) as a special hidden key. With ACLs, you can grant access to that room without making your friend an official member of the group. It's like a secret pass that allows specific access without changing the group setup.

๐Ÿ‘‰ Let's Start โœ…

  1. Check ACL permission โ“

    getfacl <file/dir>

    The permissions that you can see above are default permissions not specific to ACL permissions

  2. Set ACL permission for User ๐Ÿ‘จ

    setfacl -m "u:<user>:<permissions>" <file/dir>

    If you do ls -l after setting ACL permissions, you can see + at the end of file permissions, which represents ACL permissions that have been added to that file/dir.

    You can use -d along with -m to allow all files or directories to inherit ACL entries from the directory it is within

  3. Set ACL permission for Group ๐Ÿ‘ฅ

    setfacl -m "g:<group>:<permissions>" <file/dir>

    You can use -d along with -m to allow all files or directories to inherit ACL entries from the directory it is within

  4. Remove specific User ACL permission ๐Ÿ‘คโŽ

    setfacl -x "u:<user>" <file/dir>

    The user:user1:-wx has been removed

  5. Remove specific Group ACL permision๐Ÿ‘ฅโŽ

    setfacl -x "g:<group>" <file/dir>

    The group:user1:rwx has been removed

  6. Remove all ACL permissions ๐Ÿ—‘๏ธ

    setfacl -b <file/dir>

    Removed all ACL permissions

๐Ÿ‘‰ Conclusion ๐Ÿ‘€

You just learned ACL ๐Ÿ˜…

Happy Learning!!! ๐Ÿ‘‹