The id
command in Bash is used to display the user and group information for the current user or a specified user. It provides details such as the user ID (UID), group ID (GID), and the groups to which the user belongs.
The basic syntax of the id
command is as follows:
id [options] [username]
-u
: Display only the effective user ID.-g
: Display only the effective group ID.-G
: Display all group IDs the user belongs to.-n
: Display names instead of numeric IDs.-r
: Display the real ID instead of the effective ID.Here are some practical examples of using the id
command:
id
id username
id -u
id -g
id -G
id -n
id
without any options to quickly check your own user and group information.id -Gn
to get the group names of the current user.