Created a UID>=1000 report

This commit is contained in:
Ezri Brimhall 2024-10-01 18:04:11 -06:00
parent 683f5de32c
commit d211e95db4
Signed by: ezri
GPG Key ID: 3DA1675C4E9B9216

14
user-report/report.sh Executable file
View File

@ -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