How to View User and Group IDs Using the id Command in Linux

When you attempt to execute a bash script or access a secure directory on a Linux server and the system violently throws a “Permission Denied” error, the most common cause is a mismatch between your user account and the required system group. In Linux, permissions are not just granted to individual users; they are granted to massive mathematical groups (like the `sudo` group or the `docker` group). To instantly diagnose exactly who the kernel thinks you are and what groups you currently belong to, you must use the id command.

How the id Command Works

The id command interrogates the core Linux security subsystem and outputs a highly detailed security profile containing your exact mathematical identifiers.

Simply type the command into the terminal and press Enter:

id

The server will instantly output a chaotic string of data that looks like this:

uid=1000(jsmith) gid=1000(jsmith) groups=1000(jsmith),4(adm),27(sudo),120(docker)

Understanding the Output Metrics

To accurately diagnose a permission error, you must understand exactly what these three distinct variables mean.

  • uid (User ID): This is your primary mathematical identifier. While a human reads the name “jsmith,” the Linux kernel only understands the raw number (1000). If this number is 0, you are the absolute root administrator.
  • gid (Primary Group ID): Every single user in Linux is automatically assigned their own personal, primary group upon creation. When you create a brand new file, it will automatically inherit this specific group ownership.
  • groups (Supplementary Groups): This is the most critical section for troubleshooting. It lists every single secondary group your account has been added to. If you are trying to execute a docker container and the number 120(docker) is missing from this list, the kernel will instantly block you.

Checking Other Users

If you are a system administrator, you do not need to physically log in as a different user to check their security clearance. You can simply append their exact username to the end of the command.

id tjones

The terminal will instantly output the complete security profile for tjones, allowing you to quickly verify if they have been successfully added to the sudo group before you assign them administrative tasks.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.