/etc/group: check which users belong to each group
In this new ‘quick tip’ I will show you the value of the
/etc/group, a system file you probably haven’t opened yet but displays useful information about users and groups. This file is readable by anyone, so you don’t need superuser privileges to open it.
/etc/group is similar to this:
$ cat /etc/group root:x:0:brltty,root sys:x:3:bin mem:x:8: ftp:x:11: mail:x:12: [truncated output]
You can see each group on the system: in each line you can see group name, encrypted password (nowadays is indicated with just an ‘x’ and the encrypted password is stored in
/etc/gshadow, like with
/etc/shadow), group ID (GID) and the users who belong to that group (separated by commas).
For example, you can use this file to see which users belong to ‘root’, ‘sudo’ or ‘wheel’ groups, and have superuser (administrator) privileges (if ‘sudo’ and ‘wheel’ groups are allowed to run commands as root, check
If you want to edit this file, it’s better to use tools like
groupadd, etc. See User Management in Linux.
If you have any suggestion, feel free to contact me via social media or email.