I want to create a bash script that must be executed with sudo but should take into account the name of the non-sudo user who executed it. So if user
sudo ./myscript.sh I would like
myscript.sh to know
bob was the one who executed it.
Let's look inside
USER=$(whoami) # Do something that takes into account the username.
How can I know the name of the user who spawned the process? More specifically, what should I use instead of
whoami to get
bob and not