Reader small image

You're reading from  Mastering Linux Security and Hardening

Product typeBook
Published inJan 2018
Publisher
ISBN-139781788620307
Edition1st Edition
Tools
Right arrow
Author (1)
Donald A. Tevault
Donald A. Tevault
author image
Donald A. Tevault

Donald A. Tevault - but you can call him Donnie - got involved with Linux way back in 2006, and has been working with it ever since. He holds the Linux Professional Institute Level 3-Security certification, and the GIAC Incident Handler certification. Donnie is a professional Linux trainer, and thanks to the magic of the internet, teaches Linux classes literally the world over from the comfort of his living room. He's also a Linux security researcher for an IoT security company.
Read more about Donald A. Tevault

Right arrow

Setting the SGID bit and the sticky bit on the shared directory


I've told you before that it's a bit of a security risk to set either the SUID or SGID permissions on files, especially on executable files. But, it is both completely safe and very useful to set SGID on a shared directory.

SGID behavior on a directory is completely different from SGID behavior on a file. On a directory, SGID will cause any files that anybody creates to be associated with the same group with which the directory is associated. So, bearing in mind that the SGID permission value is 2000, let's set SGID on our marketing directory:

[donnie@localhost /]$ sudo chmod 2770 marketing
[sudo] password for donnie:

[donnie@localhost /]$ ls -ld marketing
drwxrws---. 2 nobody marketing 28 Nov 13 15:41 marketing
[donnie@localhost /]$

The s in the executable position for the group indicates that the command was successful. Let's now let Vicky log back in to create another file:

[donnie@localhost /]$ su - vicky
Password:
Last login...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Mastering Linux Security and Hardening
Published in: Jan 2018Publisher: ISBN-13: 9781788620307

Author (1)

author image
Donald A. Tevault

Donald A. Tevault - but you can call him Donnie - got involved with Linux way back in 2006, and has been working with it ever since. He holds the Linux Professional Institute Level 3-Security certification, and the GIAC Incident Handler certification. Donnie is a professional Linux trainer, and thanks to the magic of the internet, teaches Linux classes literally the world over from the comfort of his living room. He's also a Linux security researcher for an IoT security company.
Read more about Donald A. Tevault