Say I have the following bash script:
#!/bin/bash
echo $( whoami )
This is what it outputs with and without sudo:
alix@netbook:~$ ./test.sh
alix
alix@netbook:~$ sudo ./test.sh
root
The script executes several commands that require superuser priviledges, but I also want to add the original executing user to a group. Is there any command that returns alix
if I run sudo ./test.sh
?
Found the solution in a related answer:
And the output: