File Permissions
chmod [mode] [file]
- Changes file/directory permissions
- Modes: numeric (755) or symbolic (u+x)
chown [user]:[group] [file]
- Changes file ownership
- Use : to separate user and group
chgrp [group] [file]
- Changes group ownership only
Permission Modes
chmod 755 [file]
- rwxr-xr-x (owner: rwx, others: rx)
chmod u+x,g-w,o=r [file]
- Add execute for user, remove write for group
- Set read-only for others
chmod -R 644 [directory]
- Recursive permission change
- rw-r–r– for all files in directory
Special Permissions
chmod +t [directory]
- Sets sticky bit (typically /tmp)
chmod u+s [file]
- Sets SUID bit
chmod g+s [directory]
- Sets SGID bit
Verification
ls -l [file]
- Shows detailed permissions
- Format: -rwxrwxrwx owner group
stat [file]
- Detailed file information
- Octal and symbolic permissions
namei -l [path]
- Shows permissions for entire path
Default Permissions
umask
- Shows current umask value
- Default permissions for new files
umask 022
- Sets umask (subtracts from 666/777)
Example
|
|