CMDB-Server/root/Users/delusers.sh

25 lines
474 B
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/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