setfacl – Set File Access Control List

Sets Access Control Lists (ACLs) – adds permissions to files and directories for a user that is not a member of a group owning them.

Install ACL tools

apt -y install acl

Gives a read permission to user for target directory and sub directories and files, although the target directory is owned by another user:

setfacl -R -m u:username:r /target.dir

By adding wx parameters, user gets both write and execute permission:

setfacl -R -m u:username:rwx /target.dir

 For single file:

setfacl -R -m u:username:rwx file.name

Read ACLs:

getfacl /target.dir or file.name

Prerequisite for using ACL is that the file system is mounted with “acl”. This can be checked using:

tune2fs -l /dev/disk.partition

The output should contain a line: Default mount options: user_xattr acl, meaning that partition is mounted using acl and is suitable for setfacl.

Example that solves my problem with files downloaded by qBittorrent:

setfacl -R -m "u:user.name:rwx" /path.to.qbittorrent.download

Leave a Comment

Tested on Ubuntu & Pop OS