Simply put, why is this? Wouldn't it make more sense that sudo echo whoami
returns root too?
Cheers
me:~$ whoami
me
me:~$ sudo whoami
root
me:~$ sudo echo `whoami`
me
This is happening because whoami
get substituted prior the sudo and echo. Basically:
sudo echo `whoami`
first becomes
sudo echo me
and then it sudo get executed.