Group names and membership are stored in /etc/group file and you can use a program like sed, awk, or cut to extract all the group names.
Example:
List all group names along with group members:
1 2 |
## list all group names along with membership cat /etc/group |
List all available group names in Linux:
1 2 |
## list only group names cut -d: -f1 /etc/group |
List all available user names in Linux:
1 2 |
## list only user names cut -d: -f1 /etc/passwd |