r/linuxadmin • • Dec 17 '20

[deleted by user]

[removed]

9 Upvotes

19 comments sorted by

View all comments

4

u/michaelpaoli Dec 17 '20

advice sticky

$ chmod +t ...

2

u/Sparklemotionbelieve Dec 17 '20

Chmod 1777 ?

1

u/michaelpaoli Dec 18 '20

Well, yeah, but ... don't necessarily need give rwx to all - which is what the 777 portion of your 1777 does, though yes, would typically be 1777 on directories needing public write access, e.g. /tmp and /var/tmp directories.

But, could have a directory with more restricted permissions, e.g.:

$ ls -ld /var/mail
drwxrwsr-t 2 root mail 4096 Dec 17 14:25 /var/mail
$ 

Lacking world write on the above, those that are neither user root nor member of group mail, cannot create/remove/rename items in the directory. However, with the sticky bit set, those that aren't root, even if they're member of group mail, cannot remove/rename items in the directory which they don't own. Also, with the SGID set, any items created in the directory will have group ownership of mail, and in the case of directory being created, it will likewise have its SGID bit set.