Skip to content

Commit

Permalink
Add userclean.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
willnode committed Jun 4, 2024
1 parent c9b8a45 commit bf47fbc
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions userclean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# deletes orphan linux users
rm -rf /var/lib/sss/db/*
getent passwd | sort -t: -k6 | while IFS=: read -r u _ _ _ _ d _
do
if [[ "$d" =~ ^/home/ ]] && ! [[ -d "$d" ]]; then
printf 'Directory %q missing for user: %q\n' "$d" "$u"
userdel -r $u
fi
done

0 comments on commit bf47fbc

Please sign in to comment.