How to View ACLs using getfacl
In Linux, Access Control Lists—or ACLs—allow you to set more advanced permissions than the traditional user-group-other model. You can give specific users or groups read, write, or execute permissions on a file or directory—even if they're not the owner.
In this tutorial, you’ll learn how to view ACLs on any file or directory using the getfacl command.
Step 1: Open your Terminal
You can open the terminal on your Linux system using Ctrl + Alt + T or from your application menu.
Step 2: Check if ACL is supported
Most modern Linux filesystems like ext4 support ACLs, but they may need to be enabled. To check if it's supported on a mounted partition, you can use:
mount | grep acl
If your partition is mounted with acl, you're good to go.
Step 3: Use getfacl to view ACLs
The basic syntax is:
getfacl <filename or directory>
Let’s try an example:
getfacl myfile.txt
If ACLs are set, you might see output like this:
# file: myfile.txt
# owner: alice
# group: alice
user::rw-
user:bob:r--
group::r--
mask::r--
other::r--
Let’s break that down:
user::rw-– The file owner's permissionsuser:bob:r--– Bob has read-only accessgroup::r--– The group’s permissionsmask::r--– The maximum effective permissions for users and groups (except the owner)other::r--– Everyone else’s permissions
Step 4: View ACLs on a directory
You can also use getfacl on directories:
getfacl /home/alice/docs
This will list default and specific ACLs set on the directory. For example:
# file: home/alice/docs
# owner: alice
# group: alice
user::rwx
user:bob:r-x
group::r-x
mask::r-x
other::r-x
Extra Tip: List recursively
To view ACLs recursively (including all subfolders and files), use:
getfacl -R /path/to/directory
Summary
The getfacl command is your friend when you're dealing with advanced permissions in Linux. Whether you're auditing access or troubleshooting user access issues, it's a powerful tool to inspect what permissions are in place.
Coming up next, we’ll learn how to set ACLs using setfacl.
