My notepad

Chris' IT notes…
← Back

Linux ACL examples

Group permissions are NO LONGER related to group. It's a MASK!

sh
# setfacl -R -m u:apache:rwx html/
# getfacl html/
# file: html/
# owner: root
# group: root
user::rwx
user:alphausr:rwx
user:caesar:rwx
group::r-x
mask::rwx
other::r-x

To remove ACL as this is a temporary user and reinstate alphausr;

sh
cd /var/www/; setfacl -R -b html/; setfacl -R -m u:alphausr:rwx html/

DEFAULT ACL

sh
# setfacl -m d:u:apache:rwx html/

BACKUP

sh
# getfacl -R /var/www/html/ > /root/html.perm

RESTORE (need to be in / )

sh
# cd /
# setfacl --restore=/root/html.perm

ACL for Wordpress

sh
APACHE_ROOT=/var/www/vhosts/
SITE=mydomain.com
USERNAME=ftpuser
cd $APACHE_ROOT
setfacl -m d:u:apache:rwx .
setfacl -R -m u:apache:rwx .
find . -type d | xargs chmod 775
find . -type f | xargs chmod 664
chown -R $USERNAME $SITE
getfacl $SITE
# file: document_root
# owner: <username> <<<<<<< check this
# group: root
user::rwx <<<<<<< this
user:apache:rwx <<<<<<< and this :)
group::rwx
mask::rwx
other::r-x