I want this answer by Linux#!/bin/bash: Using (while) Loops. Using the 3 scripts in the Screenshot written: convert each individual script to a function to be called in a menu. This assignment will require the creation of a single script where the user will be able to look at a menu and determine what action they would like to take.
- a way to create a list of users and output them to a text file.
- checking if the user is able to run the commands (I.E. Are they root or in the sudo group?)
- resetting a single password or bulk passwords.
- creating a single user or creating multiple users.
- deleting a single user or deleting multiple users.
The scripts to complete the tasks should be in functions and not run until they are called upon. The menu should stay in the menu until the user decides to quit. You will need to create a case menu for the operation and call the function from the menu choices.
Script1.txt (/Week5) File Edit View Search Tools Documents Help
x
B
5
C
X
Script2.txt (/Week5)
Script1.txt 1 #!/bin/bash
File Edit View
Search
Tools Documents Help
B
5
C
X
Q
Script3.txt (~/WeekS) Search Tools Documents Help
?
3 i=1 4 last=1000
File Edit
Script2.txt X 1#/bin/bash
6 while [ $i -le $last ]; do
7 append string to users.txt file
8 i=$((i+1))
9 done
B
5
X
Q
3 if [ $(id -u) -ne 0 ]; then
4 echo "please run as root"
echo *Exiting..
Script3.txt X 1 #!/bin/bash
3 if [ $(id -u) -ne 0 ]; then
4 echo please run as root
5 echo "Exiting..
7 else
8 while read user; do
10 useradd -m $user
12 echo "$user:SeCUrityCl@$$" | chpasswd
16 passwd --expire $user > /dev/null
19 done < users.txt
20 fi
# if user is not root
# print message
# exit
7 else
8 while read user
10 do
14 done < users.txt
16 fi
# if user is root
# loop
# remove user along with home directory
# redirect any error message
# read from file user.txt
# end of if
t:aoeds gxaured Ln 20, Col 72
Ln 16, Col 60
INS
Plain Text Spaces: 4