setfacl

>Usage

setfacl allows you to set Access Control Lists (ACLs) for files and directories.

ACLs enable you to give specific permissions to users or groups that aren't reflected in the traditional owner/group/other model.

>Synopsis

$ setfacl -m u:username:rwx file.txt [option] [option]

>Options

-m (modify)

Modifies the ACL of a file or directory.

Example 1:

Dots

-zsh

> setfacl -m u:username:rwx file.txt


-x (remove)

Removes specific ACL entries.

Example 2:

Dots

-zsh

> setfacl -x u:username file.txt


-b (remove all ACLs)

Removes all ACL entries from a file or directory.

Example 3:

Dots

-zsh

> setfacl -b file.txt


-d (default)

Sets default ACL entries for newly created files in a directory.

Example 4:

Dots

-zsh

> setfacl -d -m u:username:rw file.txt


-R (recursive)

Applies ACL modifications recursively to all files and subdirectories.

Example 5:

Dots

-zsh

> setfacl -R -m u:username:rwx /folder


-n (numeric)

Displays numeric ACL entries rather than symbolic ones.

Example 6:

Dots

-zsh

> setfacl -n file.txt


-k (clear default ACL)

Clears the default ACL from a directory.

Example 7:

Dots

-zsh

> setfacl -k /folder


getfacl (get ACL)

Displays the current ACL of a file or directory.

Example 8:

Dots

-zsh

> getfacl file.txt


>Quiz

Progress: Question ? out of ?

Question Title

Page written by Dusan Pavlovic