This question already has an answer here:

I have the following script:

$ ls -al setprog.sh 
-rwsrwxr-x 1 root root 52 Αυγ   2 10:23 setprog.sh

$ cat setprog.sh 

while [ True ]
    echo $(whoami)

When running it

$ ./setprog.sh 

Why the process owner indicated by ps (real user) and and the user by whom the program is executed (effective user?) match? Shouldn't the one of them be root given that the script is owned by him?

$ ps aux | grep -i setpr
pkaramol 10294 18.0  0.0  12888  3268 pts/0    S+   10:45   0:00 /bin/bash ./setprog.sh
pkaramol 16746  0.0  0.0  14432  1104 pts/1    S+   10:45   0:00 grep --color=auto -i setpr

marked as duplicate by Kusalananda bash Aug 2 '18 at 7:58

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Why echo $(whoami) instead of just whoami? Why test on the string True and not while true? – Kusalananda Aug 2 '18 at 7:53
  • Because if I echo whoami instead of $(whoami) it will stdout the string whoami instead of the result of the command whoami; True vs true does not make much of a difference; – pkaramol Aug 2 '18 at 7:55
  • What I did notice through is that whenever I edit the file, the setuid bit is gone; – pkaramol Aug 2 '18 at 7:56

Browse other questions tagged or ask your own question.