close
» » How to know current user in Linux Mint?

How to know current user in Linux Mint?

Other

How to know current user in Linux MintHow to know current user in Linux Mint

I would like to tell how to get the current user name in Linux Mint (or any popular Linux distribution). I only used a few but found a few which didn't know.

The easiest way to obtain the current user is to run the following command:

whoami

Also, you can use environment variables and display the following option:
echo $USER

Also, you can retrieve a user by ID:
id -u -n

Also, you can get user's PID:
ps -o user= -p $$ | awk '{print $1}'

Good Luck!!!

Print version

Add comments

  • Local comments
  • Facebook comments
mlauzon
mlauzon 20 May 2016 14:51
Whoami: shows just my username which is expected.

echo $USER: see above.

id -u -n: see above.

ps -o user= -p $$ | awk '{print $1}': see above.
  • 0
  • bowtiesmilelaughingblushsmileyrelaxedsmirk
    heart_eyeskissing_heartkissing_closed_eyesflushedrelievedsatisfiedgrin
    winkstuck_out_tongue_winking_eyestuck_out_tongue_closed_eyesgrinningkissingstuck_out_tonguesleeping
    worriedfrowninganguishedopen_mouthgrimacingconfusedhushed
    expressionlessunamusedsweat_smilesweatdisappointed_relievedwearypensive
    disappointedconfoundedfearfulcold_sweatperseverecrysob
    joyastonishedscreamtired_faceangryragetriumph
    sleepyyummasksunglassesdizzy_faceimpsmiling_imp
    neutral_faceno_mouthinnocent
CrossOver Linux
Your working environment Other polls