Skip to content

Commit

Permalink
Add script
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkHershey committed Sep 4, 2023
1 parent afae1f8 commit 9829c52
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions linux/expire_all_user_pass.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

# This script is used to expire the password of all users in the system.

# obtain sudo permissions
sudo -v

# get all users in the system with uid >= 1000 && uid <= 60000
users=$(awk -F':' '{ if ( $3 >= 1000 && $3 <= 60000 ) print $1 }' /etc/passwd)

# exclude current user
current_user=$(whoami)
users=$(echo "$users" | grep -v "$current_user")

# expire password for each user
for user in $users; do
sudo passwd -e $user > /dev/null && echo "Expired password for user $user"
done

0 comments on commit 9829c52

Please sign in to comment.