I am currently reading a book about programming using C, I got the part where I need to write a program that displays the real uid and effective uid in which the file is running. After compiling the code using gcc , I enter the command to see the current uOwner and gOwner ls- l id_demo , the output is as follows:
-rwxrwxr-x 1 user user 8629 Sep 21 13:04 id_demo
Then I run the program itself, this is what I get:
real uid: 1000 effective uid: 1000
... so far so good. Then I enter the command to change the owner of the file:
sudo chown root:root ./id_demo
ls -l confirms that the owner has been changed to root:
-rwxrwxr-x 1 root root 8629 Sep 21 13:04 id_demo
Again, running the program shows real uid and uid as 1000. The last step after which uid should be 0: sudo chmod u+s ./uid_demo , but for me they remain as 1000, where in the book the output clearly shows the following:
real uid: 1000 effective uid: 0
Any ideas why this is happening?
UPDATE
id_demo source code:
#include <stdio.h> int main () { printf("real uid: %d\n", getuid()); printf("effective uid: %d\n", geteuid()); }
UPDATE 2 Screenshots


PLEASE, HELP. I'm going crazy. I spent 6 hours finding a solution, and I need to move on.