The uname and whoami commands in Linux

The uname and whoami commands in Linux

Here, `whoami` and `id -un` show the same account name. I love how that small equivalence makes the scope of `whoami` clear without turning it into a full account profile.

Compare the question you have with the value each command reports. That distinction helps you choose between `uname` and `whoami`.

What uname and whoami tell you

uname prints selected information about the running kernel and machine. whoami prints the account name associated with the process’s effective user ID.

They answer separate questions, so choose by the value you need.

CommandWhat it identifiesExample use
unameKernel name, when you give no optionCheck whether the kernel reports Linux
uname -rKernel releaseCompare a release with a driver requirement
whoamiEffective user nameSee which account a process runs as
Uname Default Output 1
uname command output

The image shows the default kernel-name result, Linux. It does not identify the kernel release or the distribution.

Confirm both commands are available

Both commands run from a shell and need no administrative rights, so the first check is whether your shell can locate them. The command below looks up both names.

command -v uname whoami

The output contains one executable path per command. If either path is absent, that command is unavailable in your current PATH.

Select the uname field you need

With no option, uname acts as though you passed -s. The uname manual lists the fields and their order, so use the table to select one field or the full set.

I found uname -r clearer for a kernel-release question than uname -a because its single value can be compared on its own.

OptionInformation printed
-a, –allAll known fields together, with -p and -i omitted when unknown
-s, –kernel-nameKernel name
-n, –nodenameNetwork node name, commonly the host name
-r, –kernel-releaseKernel release
-v, –kernel-versionKernel version string
-m, –machineMachine hardware name
-p, –processorNon-portable processor type, which may be unknown
-i, –hardware-platformNon-portable hardware platform, which may be unknown
-o, –operating-systemOperating-system name
uname -a

Use -r when you need the kernel release. Use -v for the kernel’s version string, which is a different field.

uname -r
Terminal output of uname -r showing kernel release 6.17.0-1020-oracle
uname -r prints the running kernel’s release field.

The displayed release belongs to the kernel running on that machine. Your system prints its own value.

Check the effective user with whoami

whoami prints the name attached to the current effective user ID. The whoami manual says its output is the same as id -un, which means both commands name the same effective account.

I saw both commands return the same account name in this shell, so the command and its documented equivalent agree.

whoami
id -un
Terminal output of whoami showing effective user ubuntu
whoami prints the effective user name for this process.

The printed name does not include group membership, so run id when groups can explain a permission result. For the next step, see how to find a user’s group in Linux or list all groups in Linux.

The account name alone does not show its sudo policy, so treat whoami as an identity check rather than a permission check. If you need to grant access, follow the guide to add a user to sudoers.

If you need another account, use useradd to create a Linux user. To rename an existing Ubuntu account, follow the steps to change a username on Ubuntu.

Separate login records from kernel and distribution details

whoami answers which effective account the process uses. The commands who and who am i query login-session records instead, while uname -r reports the kernel release.

QuestionCommandWhat the result means
Which account does this process use?whoamiEffective user name
Which users have login sessions?whoRecords of logged-in users
Which login record belongs to this terminal?who am iTerminal login entry, when one is recorded
Which IDs and groups does this process have?idUser ID, group ID, and group membership
Which kernel release is running?uname -rKernel release string
Which Linux distribution is installed?cat /etc/os-releaseDistribution name and version fields

I saw who am i return no line in this terminal, which fits the who manual because it reads the terminal’s login information from utmp.

cat /etc/os-release
Terminal output from cat /etc/os-release identifying Ubuntu 24.04.5 LTS
The os-release file identifies the distribution separately from the kernel.

The command reads the distribution’s os-release file, not a uname field. Its os-release manual describes the distribution name and version fields, while the Ubuntu version check shows that procedure on Ubuntu.

Use the field the next tool needs

When a permission result depends on the account’s groups, inspect those IDs before changing permissions. I use id for that next check because whoami intentionally returns only the effective account name.

id

Frequently asked questions

The login name recorded for a terminal can differ from a process’s effective user ID. The command you choose determines which identity you see.

What does uname print without any options?

Without an option, uname prints the kernel name. On a Linux kernel, that value is Linux.

Does whoami show the logged-in user?

whoami prints the name associated with the process’s current effective user ID. It does not report the terminal’s login record.

Does uname -r show the Linux distribution version?

No. uname -r prints the running kernel’s release. Read /etc/os-release for the Linux distribution name and version fields.