Home·Terminal commands

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

FlagMeaning
-uThe numeric user id only; 0 means root
-gThe primary group id
-GEvery group id the user is in
-nNames instead of numbers, with -u, -g or -G
-rThe real id rather than the effective one

Examples

id

Your uid, gid and every group at once.

id -u

Just the number, which scripts test against 0.

id -nG deploy

The 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