How to get current user's primary group GID on Linux

Run

id -g

to get the GID of the current user’s primary group. Example:

$ id -g
1000

You can also get the GID of another user’s primary group:

$ id -g root
0