How do I check which Linux user and groups my SSH session is using?
id shows the identity and groups used by a process. This matters because SSH login names, sudo commands and service accounts may operate with different privileges. A successful login does not imply permission to administer every application or read every customer file.
Before you start
- An authorised SSH session on the Linux server.
Instructions
1. Inspect the current session
Run the command without a username to inspect this shell’s live group membership. The numeric identifiers are what filesystem access checks ultimately use.
id
id -unid reports user and group identifiers; -un prints the effective username. This is a read-only identity check.
2. Compare the account record
Use the intended account name when checking its configured groups. Changes to group membership may not appear in an already-running shell.
id adminuser
getent passwd adminuserThe named lookup checks the account database and its configured groups. getent may query directory services as well as local files. It does not reveal a password.
Check the result
- The session username and expected groups match the intended administrator or application role. Reconnect after an approved group change to test a fresh session.
Troubleshooting
- A new group appears in id adminuser but not id
- The current process retains its previous supplementary groups. Open a new authenticated session.
- The account is not found locally
- Check whether identity comes from a directory service and whether that service is reachable.
Official references
Use the documentation for your installed version when a flag, service name or platform feature differs.
