File permissions are the foundation of Linux security. Every file and directory has an owner, a group, and a set of permissions.
Permission Notation
ls -la /var/www/
drwxr-xr-x 5 www-data www-data 4096 Mar 18 html
-rw-r--r-- 1 www-data www-data 612 Mar 18 index.html
chmod
chmod 755 script.sh
chmod 644 config.ini
chmod 600 id_rsa
chmod u+x script.sh
chmod g+w shared-file.txt
chown
sudo chown www-data:www-data /var/www/html/ -R
sudo chgrp developers /opt/project/ -R
Special Permissions
chmod 4755 /usr/bin/passwd # SUID
chmod 2775 /opt/shared/ # SGID
chmod 1777 /tmp/ # Sticky bit
find / -perm -4000 -type f 2>/dev/null
POSIX ACLs
setfacl -m u:john:rwx /opt/project/
getfacl /opt/project/
setfacl -d -m g:developers:rwx /opt/project/
Explore our Linux eBook collection.