/ factorpad.com / tech / linux-essentials / id-command.html
An ad-free and cookie-free website.
Beginner
Learn to find user and group information at the Linux command line.
Videos can also be accessed from the Linux Essentials Playlist on YouTube.
Linux id Command Summary with Examples (3:32)
Our seventy-seventh word, or command to memorize is
id
from our category
Users.
id
allows you to show user and group
information.
-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.
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.
And there's the group number, but let's make it more descriptive with an
-n
at the end.
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).
And the -n
for name.
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.
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.
For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:
If I've helped you in some way today. Please consider giving back in some way.
chown
command,
hit Back.su
command, click Next./ factorpad.com / tech / linux-essentials / id-command.html
A newly-updated free resource. Connect and refer a friend today.