id
Permissions
Usage
id [user]Prints the user and group ids a process runs with; id -u returning 0 means root, which is the standard way a script checks for administrator rights.
Common flags
| Flag | Meaning |
|---|---|
| -u | The numeric user id only; 0 means root |
| -g | The primary group id |
| -G | Every group id the user is in |
| -n | Names instead of numbers, with -u, -g or -G |
| -r | The real id rather than the effective one |
Examples
idYour uid, gid and every group at once.
id -uJust the number, which scripts test against 0.
id -nG deployThe group names of another user.
Numeric and symbolic modes name the same thing: 755 and u=rwx,go=rx are the same permission.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does id do?
Prints the user and group ids a process runs with; id -u returning 0 means root, which is the standard way a script checks for administrator rights.
Q. How do I type it?
id [user] — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
5 are listed here; the full set is in man id. This command sits under Permissions.
Related commands
man page: man id