The USER env variable is unchanged after gaining root access.
[user1@comp]$ echo $USER
user1
Logged in the system as 'user1'. Now check the output after gaining root access.
[user1@comp]$ su
Password:
[root@comp]# echo $USER
user1
If I were to login as 'root' user, then USER env is set to 'root'. There is no issue there. This behavior was observed in Fedora and CentOS. Why is the env variable not updated?
$USERenv variable often doesnt get updated when you switch to root, you can trywhoamior some other alternative like , I have readwho am iworks for some people too (but not for me on Ubuntu)