# Ensure All Groups Referenced in /etc/passwd Exist in /etc/group

- Source: https://support.icompaas.com/support/solutions/articles/62000235396-ensure-all-groups-referenced-in-etc-passwd-exist-in-etc-group
- Section: [Solutions](https://support.icompaas.com/support/solutions) › [CIS Amazon Linux 2 Benchmark v3.0.0](https://support.icompaas.com/support/solutions/62000112696) › [CIS Amazon Linux 2 Benchmarks](https://support.icompaas.com/support/solutions/folders/62000169265)
- Last updated: 2026-05-29
- Publisher: iCompaas, Inc. (https://www.icompaas.com)

Profile Applicability: Level 1

  

Description:  
 Each user account in /etc/passwd references a primary group ID (GID). It is important that every GID referenced corresponds to an existing group in /etc/group. Missing group entries can cause permission and access issues.

  

Rationale:  
 Ensuring all groups in /etc/passwd exist in /etc/group prevents permission inconsistencies and potential security issues due to orphaned group references.

  

**Impact:  
** **Pros:**

-   Maintains consistency in user-group mappings.
    
-   Prevents access control errors and permission issues.
    

**Cons:**

-   Creating missing groups may require coordination with system policies.
    

Default Value:  
 Some systems may have inconsistencies due to manual configuration or migration.

  

Pre-requisites:

-   Root or sudo privileges to audit and modify group and user configurations.
    

Remediation:

### Test Plan:

Using Linux command line:

1.  List all unique GIDs referenced in /etc/passwd:
    
    awk -F: '{print $4}' /etc/passwd | sort -u
    
2.  List all GIDs in /etc/group:
    
    awk -F: '{print $3}' /etc/group | sort -u
    
3.  Identify GIDs in /etc/passwd not found in /etc/group:
    
    comm -23 <(awk -F: '{print $4}' /etc/passwd | sort -u) <(awk -F: '{print $3}' /etc/group | sort -u)
    
4.  Verify that this list is empty.  
      
    

Implementation Plan:

Using Linux command line:

1.  For each missing GID, create a corresponding group:
    
    groupadd -g <missing\_gid> <group\_name>
    
2.  Confirm group creation and update any affected configurations.  
      
    

Backout Plan:

Using Linux command line:

1.  Remove incorrectly created groups if needed:
    
    groupdel <group\_name>
    
2.  Reassess system configurations.  
      
    

References:

-   CIS Amazon Linux 2 Benchmark v3.0.0
    
-   [NIST SP 800-53 Revision 5 - AC-6  
      
    ](https://csrc.nist.gov/publications/detail/sp/800-53/rev-5/final#ac-6)

## Related compliance guidance

- [SOC 2 compliance: a practical implementation guide for cloud-native SaaS teams](https://support.icompaas.com/compliance/soc-2-trust-services-criteria): Configuration checks like this one are the technical half of a SOC 2 / ISO 27001 programme — the guide shows where they fit, what else an auditor expects, and how to evidence them.
- [ISO/IEC 27001:2022 compliance: a practical implementation guide](https://support.icompaas.com/compliance/iso-27001-2022): ISO 27001 Annex A.8 (technological controls) is where cloud hardening evidence lands; the guide shows how to run the ISMS around it.
