-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_del_batch.sh
54 lines (39 loc) · 1.15 KB
/
user_del_batch.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
# Developed by DevTae@2023
# declare users with username and password
declare -A pwds_normal
pwds_normal["user1"]="password1"
pwds_normal["user2"]="password2"
pwds_normal["user3"]="password3"
declare -A pwds_admin
pwds_admin["admin1"]="password1"
pwds_admin["admin2"]="password2"
pwds_admin["admin3"]="password3"
# create the users using deluser script
echo "the account removing process is starting ..."
for _key in ${!pwds_normal[@]}
do
deluser $_key
echo "the user ${_key} is removed."
done
for _key in ${!pwds_admin[@]}
do
deluser $_key;
echo "the admin ${_key} is removed."
done
echo "the account removing process is completed."
# the section of removing sudoers.d files
echo "the process of the removing sudoers.d is starting ..."
for _key in ${!pwds_normal[@]}
do
sudo rm /etc/sudoers.d/$_key
sudo rm -r /home/$_key
echo "the user ${_key}'s sudoers.d file is removed."
done
for _key in ${!pwds_admin[@]}
do
sudo rm /etc/sudoers.d/$_key
sudo rm -r /home/$_key
echo "the admin ${_key}'s sudoers.d file is removed."
done
echo "the process of the removing sudoers.d is completed."