Finding your current login identity — classic Unix commands Which command prints information about the current login (user and terminal) in a traditional Unix environment?

Difficulty: Easy

Correct Answer: who am i

Explanation:


Introduction / Context:
Unix provides several commands to reveal identity or session information. Distinguishing among them helps when auditing sessions, writing scripts, or troubleshooting access problems.



Given Data / Assumptions:

  • The system provides classic who functionality.
  • We want to report the current user and associated terminal session.
  • We are not simply printing the working directory or command path.


Concept / Approach:

who am i (equivalently who -m on many systems) displays the entry for the current terminal, effectively showing who you are logged in as and on which TTY. Related commands include whoami (prints just the username) and id (UID/GID and groups). The options listed do not include whoami, so the best match is who am i.



Step-by-Step Solution:

Identify the requirement: current login identity for this session.Choose classic tool: who restricted to current terminal.Use form who am i to output the entry for the current TTY.Confirm output includes username and terminal.


Verification / Alternative check:

Run who am i and compare with who (shows all logins), whoami (just the username), and id (numeric IDs). You will see the difference clearly.



Why Other Options Are Wrong:

  • i /4: not a valid Unix identity command.
  • pwd: prints working directory, not who you are.
  • which: locates a command in your PATH.
  • None of the above: incorrect because who am i fits the requirement.


Common Pitfalls:

Confusing who am i with whoami; both are useful but return different information. Also, on some minimal systems, who may behave slightly differently; who -m is a common equivalent.


Final Answer:

who am i

More Questions from Unix

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion