The Wayback Machine - https://web.archive.org/web/20240621071306/https://www.geeksforgeeks.org/access-control-listsacl-linux/
Open In App

Access Control Lists(ACL) in Linux

Last Updated : 02 May, 2018
Improve
Improve
Like Article
Like
Save
Share
Report

What is ACL ?
Access control list (ACL) provides an additional, more flexible permission mechanism for file systems. It is designed to assist with UNIX file permissions. ACL allows you to give permissions for any user or group to any disc resource.

Use of ACL :
Think of a scenario in which a particular user is not a member of group created by you but still you want to give some read or write access, how can you do it without making user a member of group, here comes in picture Access Control Lists, ACL helps us to do this trick.

Basically, ACLs are used to make a flexible permission mechanism in Linux.

From Linux man pages, ACLs are used to define more fine-grained discretionary access rights for files and directories.

setfacl and getfacl are used for setting up ACL and showing ACL respectively.

For example :

getfacl test/declarations.h

Output:

# file: test/declarations.h
# owner: mandeep
# group: mandeep
user::rw-
group::rw-
other::r--

List of commands for setting up ACL :

1) To add permission for user
setfacl -m "u:user:permissions" /path/to/file

2) To add permissions for a group
setfacl -m "g:group:permissions" /path/to/file 

3) To allow all files or directories to inherit ACL entries from the directory it is within
setfacl -dm "entry" /path/to/dir

4) To remove a specific entry
setfacl -x "entry" /path/to/file

5) To remove all entries
setfacl -b path/to/file

For example :

setfacl -m u:mandeep:rwx test/declarations.h

Modifying ACL using setfacl :
To add permissions for a user (user is either the user name or ID):

# setfacl -m "u:user:permissions" 

To add permissions for a group (group is either the group name or ID):

# setfacl -m "g:group:permissions" 

To allow all files or directories to inherit ACL entries from the directory it is within:

# setfacl -dm "entry" 

Example :

setfacl -m u:mandeep:r-x test/declarations.h

See below image for output :

setfacl and getfacl

View ACL :
To show permissions :

# getfacl filename

Observe the difference between output of getfacl command before and after setting up ACL permissions using setfacl command.
There is one extra line added for user mandeep which is highlighted in image above.

Output:

change permissions

The above command change permissions from rwx to r-x

Remove ACL :
If you want to remove the set ACL permissions, use setfacl command with -b option.
For example :

remove set permissions

If you compare output of getfacl command before and after using setfacl command with -b option, you can observe that there is no particular entry for user mandeep in later output.

You can also check if there are any extra permissions set through ACL using ls command.

check set acl with ls

Observe the first command output in image, there is extra “+” sign after the permissions like -rw-rwxr–+, this indicates there are extra ACL permissions set which you can check by getfacl command.

Using Default ACL :
The default ACL is a specific type of permission assigned to a directory, that doesn’t change the permissions of the directory itself, but makes so that specified ACLs are set by default on all the files created inside of it. Let’s demonstrate it : first we are going to create a directory and assign default ACL to it by using the -d option:

$ mkdir test && setfacl -d -m u:dummy:rw test

Similar Reads

Process Control Commands in Unix/Linux
Process control commands in Unix are: bg - put suspended process into background fg - bring process into foreground jobs - list processes bg Command : bg is a process control command that resumes suspended process while keeping them running in the background. User can run a job in the background by adding a "&" symbol at the end of the command.
3 min read
How to Control Systemd Services on Remote Linux Server
Linux, SysV, and LSB init scripts are compatible with Systemd, a system and service manager. Aggressive parallelization capabilities are offered by Systemd, which also offers on-demand daemon starting and uses Linux cgroups to keep track of processes. Systemd also supports system snapshotting and restore, maintains mount and automount points, and i
2 min read
Fix Brightness Control Not Working for Kali Linux
Brightness control issues can be frustrating when using Kali Linux, an operating system. Changing scree­n brightness on Kali Linux can be tricky sometime­s. Brightness control is important for user comfort and saving battery life­. But different things like hardware­, drivers, and settings may cause issue­s. The brightness may not work properly due
6 min read
access command in linux with examples
In Linux, the access command is used to check whether the calling program has access to a specified file. It can be used to check whether a file exists or not. The check is done using the calling process's real UID and GID. int access (const char *pathname, int mode);Here, the first argument takes the path to the directory/file and the second argum
3 min read
OpenDoor - OWASP Directory Access Scanner in Kali Linux
Brute-Forcing is an automated process through which Usernames, Passwords can be detected by querying the possible credentials on the target domain login pages. We can also brute-force hidden files and directories on the target server by specifying the possible word-list which contains the phrases that will be tested on the domain. This process save
3 min read
How to Access the Dark Web Using the TOR Browser in Kali Linux
The "surface web" is the portion of the internet that is easily traceable and indexed by search engines. Only 4% of the Internet is covered by the surface web; the rest is made up of the dark web and other forms. What is Deep web & Dark web? There is a portion of the internet that is encrypted and inaccessible to standard search engines like Go
3 min read
How To Setup an Iptables Firewall to Enable Remote Access to Services in Linux
A system administrator can modify the IP packet filter rules of the Linux kernel firewall, which are implemented as various Netfilter modules, using the user-space utility application iptables. The filters are arranged in several tables, each of which has a set of rules on how to handle packets of network data. Using a set of programmable table rul
5 min read
Maintaining Access Tools in Kali Linux
Maintaining Access is the 4th phase in the ethical hacking process. In this phase, the hacker installs software or makes changes to the target machine to access the target later in time. This allows the hacker to stay connected with the target machine, thus cutting the need of starting the process from scratch for the same target. This phase is als
8 min read
How to Monitor Access Point Signal Strength with wifi-linux
In today's interconnected world, Wi-Fi has become indispensable for both personal and professional connectivity. However, ensuring a stable and secure Wi-Fi connection requires diligent monitoring of access point signal strength. In this comprehensive guide, we'll explore why monitoring access point signal strength is crucial on Linux systems and h
6 min read
How to Access All Users in Linux Using Different Commands?
Linux allows multiple users with their own custom setting and configuration to work together on the same system, even at the same time. It can even allow a particular user to access several sessions from different locations in order to work on the system. Below is a list of different commands to access the list of users in Linux: 1. less command: E
2 min read
Article Tags :