Linux command: id
Find out which user a command runs as
On a shared computer, one account might be alice, another bob. The account identifies who is running a command and which groups that person or service belongs to. The id command shows that identity. Computers use numeric user and group IDs for access checks and often show readable names beside them. The names are labels the system looks up; an ID can still be valid when its name cannot be found.
Run id with no extra value to inspect the process that called it. The output commonly includes a user ID, a primary or effective group ID, and supplementary groups. Formatting varies, especially when real and effective IDs differ. Linux can keep saved and filesystem IDs too, so id is a useful summary rather than a complete list of credentials.
Options ask for particular values:
id -u # effective user ID
id -g # effective group ID
id -G # group IDs
id -nG # group names
id -ru # real user ID
The -r option selects a real ID when used with -u, -g, or -G. Thus id -ru prints the real user ID, while id -G lists group IDs and id -nG asks for their names. Check the local id manual when a script must work across Unix-like systems.
You can also give an account name: id alice looks up the configured IDs and groups for alice. It does not inspect a process called alice or change the identity of your current shell. Without an account operand, id reports the credentials of the calling process. Neither form grants access or elevates privileges.
Real and effective IDs often match, but can differ after a set-user-ID program runs or the identity changes explicitly. Effective IDs take part in many permission checks. Supplementary groups can give additional access. Compare id with id -ru in the same shell to check whether real and effective user IDs differ; compare id -G and id -nG to see numeric groups and their resolved names. A missing group name can mean the system could not look it up, not that the group ID is invalid.
Use id when another command's result depends on who runs it. The report helps explain identity, but file permissions, access-control lists, namespaces, and application-specific rules can still affect whether an operation succeeds.





