← Rules Catalog
mediumaccess-controlverified

Ensure all local interactive users have a home directory in /etc/passwd

user-home-in-passwd · RHEL ≥ 8 · 1 impl

Description

All local interactive user accounts must have a home directory configured in the /etc/passwd file.

Rationale

Without a configured home directory, users may not be able to log in properly, and their activity may not be fully audited. A missing home directory entry may also indicate an improperly configured account.

Check → Remediate

Checkcommand
# Check all interactive users (UID >= 1000) have a home directory set
bad_users=""
while IFS=: read -r user _ uid _ _ home _; do
  if [ "$uid" -ge 1000 ] 2>/dev/null; then
    if [ -z "$home" ]; then
      bad_users="$bad_users $user"
    fi
  fi
done < /etc/passwd
if [ -z "$bad_users" ]; then
  echo "OK: All interactive users have a home directory in /etc/passwd"
  exit 0
fi
echo "FAIL: Users without home directory in /etc/passwd:$bad_users"
exit 1
expected_exit:
0
Remediatemanual
note:
For each user without a home directory configured, use usermod -d /home/<username> <username> to assign a home directory.

Framework references

STIG

V-258051 / RHEL-09-411060V-230320

NIST 800-53

IA-4CM-6

Live verification

rhel8:checkrhel9:check
#user-accounts#home-directory#passwd