Linux - Permission
Commands
Display permission detail of a file:
Backup permissions of a repository:
Restore permissions of a repository:
Grant additional access to a user:
setfacl (-R) -m {type}:{name}:{right} {file}
# Ex: setfacl -R -m u:loko:rx /data
# setfacl -m g:grp:rwx /data/file.txt
SUID/SGID/Sticky Bits
SUID Bit (4)
When the SUID bit is set on an executable file, this means that the file will be executed with the same permissions as the owner of the executable file.
Add SUID Bit:
SGID Bit (2)
SGID is similar to SUID. With the SGID bit set, any user executing the file will have same permissions as the group owner of the file.
Add SGID Bit:
Sticky Bit (1)
The sticky bit works on the directory. With sticky bit set on a directory, all the files in the directory can only be deleted or renamed by the file owners only or the root.
Add Sticky Bit:
Remove Sticky Bit:
Errors
In case of file/directory have no executable write the Bit will be in Upper case:
Change the right to fix this problem:
$ chmod 4766 plop/test.sh
$ ls -l plop/test.sh
# -rwsrw-r-- 1 user group 0 Dec 29 17:31 plop/test.sh
Examples
Set the Sticky Bit on /tmp folder:
Add SUID and SGID Bits on a file:
Extended Permission
Display extended attribute:
Set/Unset file to immutable:
Link
- https://linuxhandbook.com/suid-sgid-sticky-bit/