Linux Terminal Command: id

The id command is an essential tool in User & Permission Management. In this tutorial, we will explore what id does, look at everyday examples, and cover advanced options to supercharge your command-line workflow.


Concept & Explanation

The id command displays the active user name, numeric user ID (UID), primary group ID (GID), and all secondary groups the user belongs to.


Common Options & Syntax

id [options] [arguments]

Here are the most common flags used with id:


1. Interactive Example (Simple)

Here is how most people run the command:

# Example
id

What it does: Prints user and group IDs for the current user.


2. Power-User Example (Advanced)

For scripting and advanced diagnostics, use this configuration:

# Advanced
id -nG www-data

What it does: Prints only the group names (-n with -G) that the user ‘www-data’ belongs to.


⚙️ Warning & Common Pitfalls

[!WARNING] If a user has recently been added to a new group, id will not display it in current active terminals. You must restart the shell session or run newgrp.


Here are some related posts on cli_tty1 you might want to check out: