Linux Permissions Cheat Sheet
Read, write, execute, special bits, umask, ACLs, and sudo — the permission model that protects every Linux file and process.
Reading Modes
5ls -l FILErwx bits, owner, group, size
stat FILEModes in octal and human form
ls -l --time-style=long-iso DIR /Readable time columns
stat -c '%a %U:%G' FILEOctal mode and owner:group
drwxr-xr-xOwner rwx, group r-x, others r-x
chmod — Change Modes
9chmod 754 FILErwxr-xr-- (7 owner, 5 group, 4 other)
chmod 755 DIRrwxr-xr-x, typical for dirs
chmod 644 FILErw-r--r--, typical for files
chmod +x FILEAdd execute to all
chmod u=rw,g=r,o= FILESymbolic assignment
chmod a+r FILEMake world-readable
chmod g+w DIRAdd group write
chmod -R g+w DIRApply recursively
chmod -x FILE /Remove execute everywhere
Ownership
5chown USER FILEChange the owner
chown USER:GROUP FILEOwner and group together
chgrp GROUP FILEChange only the group
chown -R USER:GROUP DIRRecursive ownership change
chown --reference=TEMPLATE FILECopy ownership from another file
Special Bits
7chmod u+s FILESetuid — run with the owner's identity
chmod 4755 FILESetuid in octal (4 prefix)
chmod g+s DIRSetgid — inherit group for new files
chmod 2755 DIRSetgid in octal (2 prefix)
chmod +t DIRSticky bit — only owner can delete
chmod 1777 /tmpSticky in octal (1 prefix)
find / -type f -perm -4000 2>/dev/nullSpot SUID binaries
umask & Defaults
5umaskCurrent default mode mask
umask 022New files 644, new dirs 755
umask 027Tighten: 640 files / 750 dirs
umask 077Private: owner only
echo 'umask 027' >> ~/.bashrcPersist a mask for a user
ACLs
6getfacl FILEFull ACL listing
setfacl -m u:USER:rw FILEGrant a user rw
setfacl -m g:DEV:rwx DIRGrant a group rwx
setfacl -x u:USER FILERemove a user entry
setfacl -b FILEStrip all ACLs
setfacl -m u::rwx,g::r-x,o::--- FILERevise the base trio via ACL
sudo & Privilege
8sudo -lWhat a user may run
sudo -u USER CMDRun as another user
sudo -iRoot login shell
sudo -sRoot shell keeping env
visudoEdit /etc/sudoers safely
%wheel ALL=(ALL) NOPASSWD: ALLGroup sudo without a password
USER ALL=(ALL:ALL) ALLA user may run anything
sudo -vRefresh the cached timestamp
Auditing & SELinux
8find / -type f -perm -4000Locate SUID files
find / -type f -perm -2000Locate SGID files
ls -la /tmpSee the sticky-bit ownership rule
getenforceSELinux: Enforcing / Permissive / Disabled
setenforce 0Temporarily permissive
restorecon -Rv DIRRestore SELinux labels
semanage fcontext -a -t httpd_sys_content_t "/srv/web(/.*)?"Add a file-context rule
auditctl -w /etc/passwd -p wa -k passwd_changesWatch a file with auditd