Welcome To Golang By Example

Know the current user on Linux

Table of Contents

Overview

Linux command ‘whoami’ can be used to know the currently logged-in user.

Let’s see this command in action. Go to the terminal and type in the command

whoami

It will print the current user. Let’s say the current user is john then running the above command will simply print john

Output

whoami
john