How to make command `id` print different real and effective UID in Ubuntu
0
votes
2
answers
603
views
The info page of command
I'm a beginner in Linux, so beginner-friendly answers are welcome, if that is possible for the question I made. I know what is a shell program (like Bash or sh), what are environment variables, what is a C program and what are system calls such as
id
states that it will output the effective user ID if different from the real user ID. I have been trying to achieve that somehow, running the command with the Bash shell as my normal (unprivileged) user, in Ubuntu. For example, I tried the example in the answer by @Asain Kujovic [here](https://unix.stackexchange.com/a/399349/493379) but it didn't work, I get not euid
in the output whatsoever. This is the example:
osbo@osboxes:~/t$ sudo gcc -o test.bin -xc -
#include
int main() { seteuid(0); system("id"); }
EOF
osbo@osboxes:~/t$ sudo chmod +s test.bin && ./test.bin && sudo rm test.bin
uid=1000(osbo) gid=1000(osboxes) groups=1000(osboxes),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),109(netdev),113(bluetooth),119(scanner)
**EDIT**:I'm a beginner in Linux, so beginner-friendly answers are welcome, if that is possible for the question I made. I know what is a shell program (like Bash or sh), what are environment variables, what is a C program and what are system calls such as
getuid
and geteuid
. I also know what are real, effective and saved user/group ID, as related to a process a user spawns. Yet, I know very little about parent-child processes scenarios, or the strace
command.
Asked by gambarimas87
(13 rep)
Dec 7, 2023, 03:41 PM
Last activity: May 4, 2024, 08:50 AM
Last activity: May 4, 2024, 08:50 AM