diff --git a/user-report/report.sh b/user-report/report.sh new file mode 100755 index 0000000..84606e9 --- /dev/null +++ b/user-report/report.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# Returns a list of all users on the system with UID >= 1000 and their home directory and shell +# Sorted lexicographically by uid +# Uses getent passwd so as to include remote users (e.g. LDAP) in the list + +# getent passwd returns a list of all users on the system, local and remote +# it may return duplicates, since a user might be listed identically in multiple nsswitch databases (e.g. files and systemd) +for uid in $(getent passwd | cut -d: -f3 | sort | uniq); do + if [ $uid -ge 1000 ]; then + # Use AWK to parse the output of the passwd entry + getent passwd $uid | awk -F: '{print "User: " $1 ", UID: " $3 ", Home: " $6 ", Shell: " $7}' + fi +done