Quickly tell which user the shell is running as and why it matters. 31.05.2026 | reading time: 2 min Open a terminal and run a single command to learn the account your shell is using: try `whoami` and read the output to confirm identity. Try this now Run the commands below to see how `whoami` reports the current user and how sudo changes that; copy and paste into a shell to follow along. ```shell $ whoami alice $ sudo whoami root $ id -un alice ``` Beyond the simple result `whoami` prints the effective user name, which matters when scripts run with elevated privileges; use it in scripts to guard actions, remember that `whoami` differs from the login name returned by `logname`, and note that `id -u` and `id -un` give numeric and name forms respectively for more precise checks. When not to rely on whoami Avoid using `whoami` as the sole source for audit trails or to detect original login sessions because it reflects the effective identity and not necessarily the user who started the session; for session details use `last`, `who` or check process owners under `/proc`. Wrap-up and next steps `whoami` is small, fast and useful for quick checks and conditional scripts; practice combining it with `id` and environment checks to build safer scripts and consider studying system internals to understand user and process relationships better. Join Bits & Bytes Academy First class LINUX exam preparation. utilities security processes scripting