id – Print user identity in Linux
In Linux, each user has got access rights. And each user can be / is assigned to multiple groups depending upon the powers that need to be assigned to the user. Is there is an easy way to find the groups that a user belongs to ? Yes you can using the ‘
id command lists not just the groups the user belongs to but also his or her user ID and group ID. To find the groups that are assigned to the root account, log in as root and type the
id command in the terminal. On my machine, I received the following output, though you may receive a different output depending upon the Linux distribution you are using.
# id uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),19(log)
From the above output, we can see that root has UID and GID of zero and is a member of the following groups namely – bin, daemon, sys, adm, disk, wheel and log, apart from root group itself.
To know the user ID and groups of a different user, log in as root and execute the
id command passing it the username of the user.
You can also use the
id command from an ordinary user account to find the groups you belong to.