Special permissions help

I'm not understanding special permissions. Why does this not work? I thought the special permissions ran the script as the user of the script, in this case cphillips, who has permission to delete a.txt.

I just finished the Linux Essentials BTW, have not got into the RHCSA yet,  so I hope I'm not jumping the gun here, but the study guide for Linux essentials did have the special permissions mentioned in shallow detail.

[user@dbmathis1 ~]$ pwd

/home/user


[user@dbmathis1 ~]$ cat /home/cphillips/text.sh

#!/bin/bash

rm /home/cphillips/a.txt


[user@dbmathis1 ~]$ sudo chmod ug+s /home/cphillips/text.sh


[user@dbmathis1 ~]$ ls -l /home/cphillips/

total 4

-rw-r--r--. 1 cphillips accounting 0 Aug 28 20:27 a.txt

-rwsr-sr-x. 1 cphillips accounting 38 Aug 28 20:52 text.sh


[user@dbmathis1 ~]$ /home/cphillips/text.sh

rm: remove write-protected regular empty file ‘/home/cphillips/a.txt’? y

rm: cannot remove ‘/home/cphillips/a.txt’: Permission denied



  • post-author-pic
    Matthew P
    08-29-2018

    you're understanding of setuid and setgid is correct, but, most modern linux distribuition don't allow user made scripts to function like this (for security reasons). So, your script is still being executed as 'user' rather than 'cphillips'. You still see setuid/setgid being used, but it's most likely going to be with system binaries like passwd. 

  • post-author-pic
    David M
    08-29-2018

    Thanks! What in linux, specifically, checks the difference between user made scripts and system binaries?

  • post-author-pic
    David M
    08-29-2018

    Within the context of special permissions, that is.

Looking For Team Training?

Learn More