0

I want to check if I am using elevated user rights, like running su another_user and seeing my original user name / id.

All I found when researching that topic is either hardcode my own username somewhere, or examples for root user only (id=0).

I think zsh has a variable for that: $DEFAULT_USER, but it's not working in bash.

Arvigeus
  • 353
  • 3
  • 17
  • 1
    There's no concept of a default user. `DEFAULT_USER` appears to be a third party oh-my-zsh setting you can choose to set to your username to change the formatting of your prompt – that other guy Jun 25 '20 at 05:37
  • 2
    AFAIK the original ID is not saved anywhere when using su. You can try to check the ps tree and figure out if you are running under su, and you can check which user is connected to your terminal (but that's not full proof - https://stackoverflow.com/a/6566388/939457) – Sorin Jun 25 '20 at 06:31

0 Answers0