-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_action.sh
46 lines (44 loc) · 867 Bytes
/
user_action.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
menu()
{
echo "*************************"
echo "1. Add User"
echo "2. Add Group"
echo "3. List Groups"
echo "4. List Users"
echo "5. Add user to group"
echo "6. Exit"
echo "Input:"
}
input=0
while(($input!=6))
do
menu
read input
if (( $input == 1))
then
echo "Please Enter User Name:"
read usname
sudo adduser $usname
elif (( $input==2 ))
then
echo "Please Enter Group Name:"
read grname
sudo addgroup $grname
elif (( $input==3 ))
then
awk -F ":" '{print $1}' /etc/group
elif (( $input==4 ))
then
awk -F ":" '{print $1}' /etc/passwd
elif (($input==5))
then
echo "Please Enter User Name:"
read usname
echo "Please Enter Group Name:"
read grname
sudo usermod -a -G $grname $usname
elif (($input==6))
then
echo "exit !!!"
fi
done