Skip to content

7.2.7 Ensure no duplicate user names exist

Audit#

Run the following script and verify no results are returned:

1
2
3
4
5
6
7
8
#!/usr/bin/env bash
{
while read -r l_count l_user; do
if [ "$l_count" -gt 1 ]; then
echo -e "Duplicate User: \"$l_user\" Users: \"$(awk -F: '($1 == n) { print $1 }' n=$l_user /etc/passwd | xargs)\""
fi
done < <(cut -f1 -d":" /etc/group | sort -n | uniq -c)
}

Remediation#

Based on the results of the audit script, establish unique user names for the users. File ownerships will automatically reflect the change as long as the users have unique UIDs.