CMDB-Server/root/Users/delusers.sh

25 lines
474 B
Bash
Raw Normal View History

2025-07-03 17:24:43 +09:00
#!/bin/bash
echo "hands-onユーザを削除しますか (yes/no)"
read response
if [ "$response" != "yes" ]; then
exit 0
fi
FILE_U="users.txt"
FILE_P="/etc/passwd"
newusers $FILE_U
for line in `cat $FILE_U`
do
user_name=`echo $line | cut -d ':' -f 1`
txt=`cat $FILE_P | grep -e "^$user_name"`
user_id=`echo $txt | cut -d ':' -f 3`
group_id=`echo $txt | cut -d ':' -f 4`
home_dir=`echo $txt | cut -d ':' -f 6`
userdel -r $user_name
done