How to know current user in Linux Mint?

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[/simterm]
Also, you can use environment variables and display the following option:
echo $USER[/simterm]
Also, you can retrieve a user by ID:
id -u -n[/simterm]
Also, you can get user’s PID:
ps -o user= -p $$ | awk ‘{print $1}’[/simterm]

Good Luck!!!

Share to friends
Shekin
Rate author
( No ratings yet )
MintGuide.Org
Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
mlauzon
mlauzon
2022 years ago

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.