To get the details of a user and its associated group id in the Linux terminal, you can use the id
command followed by the username of the user in Linux.
TL;DR
# Get details about a username in Linux
id melvingeorge
For example, let's say we have to find the details of the user called melvingeorge
in Linux, you can use the id
command followed by the username melvingeorge
.
It can be done like this,
# Get details about a username in Linux
id melvingeorge
This will show:
- the user's user id
- the user's group id
- the user's group names
To get the details of the currently logged-in user
To get the details of the currently logged-in user, you can use the id
command without supplying any username.
It can be done like this,
# Get details about the currently logged-in user
id
To display the full name of a user
To display the fullname of a user, you can use the id
command followed by the -F
flag (the -F
refers to full name) and finally the username.
# Get the full name of a user
id -F melvingeorge
The output will be like this,
# OUTPUT:
MELVIN GEORGE
If you don't provide the username after the -F
flag, it will display the full name of the currently logged-in user.
To display only the group id's associated with a user
To display only the group IDs associated with a user, you can use the id
command followed by the -G
flag (the -G
flag refers to displaying the group IDs) and then the username.
it can be done like this,
# Get the group id's associated with a user
id -G melvingeorge
The output will look like this,
# OUTPUT:
20 501 12 61 79 80 81 98 701 33 100 204 250 395 398 399 400 702
If you don't provide the username after the -G
flag, it will display the group IDs associated with the currently logged-in user.
That's all 😃.