Linux
Permissions & Ownership
Manage read/write/execute bits with chmod and chown.
By EZ4Code Team
permissionchmodchown
Code
# Octal and symbolic modes
chmod 755 script.sh # rwxr-xr-x
chmod 644 config.yml # rw-r--r--
chmod u+x deploy.sh # add execute for owner
chmod g-w,o-r secret.key # remove group write, other read
# Recursively set dirs and files separately
find /var/www -type d -exec chmod 755 {} +
find /var/www -type f -exec chmod 644 {} +
# Ownership
chown alice:devs file.txt
chown -R alice:devs /var/www
# Special bits
chmod +t /tmp # sticky bit
chmod g+s /shared # setgid: inherit group
chmod u+s /usr/bin/binary # setuid: run as owner
# ACL for fine-grained access
setfacl -m u:bob:rw- report.txt
getfacl report.txtExplanation
Linux permissions use nine bits for owner, group, and others, set with chmod in octal (755) or symbolic (u+x) form. The setuid, setgid, and sticky bits enable privileged execution, group inheritance, and deletion restrictions respectively. ACLs (setfacl) grant fine-grained access beyond the basic user/group/other model.
More Linux Snippets
File Operations
Copy, move, link, and search files efficiently.
Process Management
List, signal, and monitor running processes.
Networking
Inspect interfaces, ports, connections, and DNS.
Package Management
Install, update, and search packages on Debian and RHEL.
Text Processing
Filter, transform, and summarize text streams.
Disk Usage
Inspect filesystems, large directories, and inodes.