From d211e95db49057f4d20d95aafcc250c11c90c1a7 Mon Sep 17 00:00:00 2001 From: Ezri Brimhall Date: Tue, 1 Oct 2024 18:04:11 -0600 Subject: [PATCH] Created a UID>=1000 report --- user-report/report.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 user-report/report.sh 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