whoami Command in Linux

Learn via video courses
Topics Covered

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

Overview

The whoami command is a simple yet powerful utility in Linux that allows you to know the username associated with the current effective user ID. This article will take you through the various aspects of the whoami command, including its syntax, options, common and advanced usages, tips, and conclusion.

Linux whoami Command Syntax

The syntax for the whoami command is as follows:

Where:

  • OPTION: Refers to the different options that can be used along with the whoami command.

whoami Command Options:

  • -h, --help: Displays a help message and exits.
  • -V, --version: Displays the version information and exits.
Free Courses by top Scaler instructors
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course

Example Usages

  • To display the username associated with the current effective user ID::

    Output:

    Explanation: This command will display the username of the current user, which in this case is john.

  • To display the current user's group name::

    Output:

    Explanation: This command will display the name of the group to which the current user belongs.

  • To display the user ID of the current user::

    Output:

    Explanation: This command will display the user ID (UID) of the current user, which in this case is 1000.

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

Tips

  • The whoami command is generally used to know the username of the current user, which can be useful in various scenarios, including scripting and programming.

  • If you want to know the username of a different user, you can switch to that user using the su command and then run the whoami command.

Advanced Use Cases of whoami Command in Linux

  • To display the name of the primary group of the current user::

    Output:

    Explanation: This command will display the name of the primary group and other groups to which the current user belongs.

  • To display the user name in the format domain/username::

    Output:

    Explanation: This command will display the username in the format domain/username.

  • To display the name of the current user in a comma-separated list::

    Output:

    Explanation: This command will display the name of the current user, separated by commas.

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Conclusion

  • The whoami command is a simple and powerful utility that can be used to display the username of the current user.

  • It can also be used to display other information such as the user's group name and ID.

  • By using the various options available with the command, you can extract even more information about the current user.

  • The whoami command is a handy tool to have in your arsenal, especially if you frequently work with Linux systems.