How to Use Access Control Lists (ACLs)

How to Use Access Control Lists (ACLs) in Linux

In this tutorial, we'll learn how to use Access Control Lists, or ACLs, to give more flexible file permission settings in Linux. ACLs let you assign different permissions to multiple users or groups—something traditional Unix permissions can't do easily.

Let's walk through this with a real example.

Step 1: Create a New File or Directory

We’ll start by creating a directory named project.

mkdir project
cd project
touch report.txt

Step 2: Check Current Permissions

Let's check who can access the file:

ls -l report.txt
-rw-r--r-- 1 youruser yourgroup 0 Jul 2 11:00 report.txt

By default, only the owner can write. Others can only read.

Step 3: Enable ACL Support (usually pre-enabled)

Most modern Linux filesystems support ACL by default. But to be sure, run:

mount | grep acl

If you don’t see anything, check if the partition is mounted with ACL support. You may need to modify /etc/fstab and remount.

Step 4: Give Another User Permission Using ACL

Now let's say you want to give another user—let’s say alice—write access to report.txt.

setfacl -m u:alice:rw report.txt

-m means “modify ACL”, u:alice:rw means user alice gets read+write.

Step 5: View the ACLs

To see what ACLs are set:

getfacl report.txt
# file: report.txt
# owner: youruser
# group: yourgroup
user::rw-
user:alice:rw-
group::r--
mask::rw-
other::r--

Step 6: Add Group Permissions

You can also grant access to an entire group:

setfacl -m g:designers:r report.txt

This gives read-only access to the designers group.

Step 7: Remove an ACL

To remove a specific ACL entry:

setfacl -x u:alice report.txt

To remove all ACL entries:

setfacl -b report.txt

Wrap-up

And that’s it! Using ACLs, you can assign different levels of access to different users or groups—without changing ownership or default file permissions.

✅ Try it out yourself. Create a test file and give a friend access using ACL!

Happy learning 👨‍💻


Comments

💬 Please keep your comment relevant and respectful. Avoid spamming, offensive language, or posting promotional/backlink content.
All comments are subject to moderation before being published.


Loading comments...