FactorPad
Build a Better Process

Linux id Command Summary with Examples

Linux id allows you to show user and group information.
  1. Purpose - Learn what id is for and how to find help.
  2. Options - Review a few common options and arguments.
  3. Examples - Walk through code examples with id.
  4. A tip - Finish off with one more insight.
face pic by Paul Alan Davis, CFA
Updated: February 24, 2021
In this tutorial on Linux id, 77 of 100, below find a 3-4 minute introductory video, a text-based tutorial and all of the code examples from the video.

Outline Back Tip Next

/ factorpad.com / tech / linux-essentials / id-command.html


An ad-free and cookie-free website.


Examples of the Linux id Command

Beginner

Learn to find user and group information at the Linux command line.

Video Tutorial

Videos can also be accessed from the Linux Essentials Playlist on YouTube.

Linux id Command Summary with Examples (3:32)

Video Script

The Command and Why You Need It

Our seventy-seventh word, or command to memorize is id from our category Users.

id allows you to show user and group information.

Common Linux id Options
-options description
--help Print help screen
-G, --groups Show all group IDs
-u, --user Show user ID

Recall from the previous video (tutorial) on chown, we set file ownership to user and groups. We also saw a text file that stores group information (using cat /etc/group). Now we'll get a quick view of our current memberships.

Before we start, it helps to think of commands as mini programs and most follow this structure: command -option(s) argument(s).

The id command has 10 options, and an argument optionally is the username.

Like most commands, help is available with double-dash --help. The -G option shows Group IDs (GID) and -u shows User IDs (UID), so yes, all groups and users are given an identification number.

So why is id an important command? Well, it may help to see which groups you're in so you can identify what responsibilities come with your membership. And now you know how to do that.

Demonstration

Okay, the best way to embed this in your memory is by typing in your own terminal window.

Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.

Here we go. Let's start by with an id -G for paul.

$ id -G paul 1001

And there's the group number, but let's make it more descriptive with an -n at the end.

$ id -Gn paul paul

And that looks better. Again, this could be a long list if for example I had multiple different groups and they had long names.

Then on the user side, id -u for the User ID (UID).

$ id -u paul 1001

And the -n for name.

$ id -un paul paul

And last, the default behavior, of simply id shows all the info in one place, which may get messy if you're part of a lot of groups.

$ id uid=1001(paul) gid=1001(paul) groups=1001(paul)

A Final Tip

Okay now you know how to use id. And you know the syntax for commands, options and arguments.

One last tip about the id command. So we saw who we are with the whoami command in video (tutorial) 13 and now with id we can find our User ID (UID) and group membership (GID). Here are two others we won't afford a whole video to, first is the who command which shows you who is logged in currently and second is w which shows you what they're doing. Interesting.

Okay, thanks for visiting today. I hope this was a helpful introduction to the id command.


Learn More About The Series

For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:


What's Next?

If I've helped you in some way today. Please consider giving back in some way.

Outline Back Tip Next

/ factorpad.com / tech / linux-essentials / id-command.html


linux id command
find uid
linux id
linux user id
linux uid
uid linux
uid gid
gid linux
get uid
change user id linux
know uid
linux user management
linux user group
linux remove user from group
linux show groups
linux show user
user id examples
man id

A newly-updated free resource. Connect and refer a friend today.