Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Script 3 Using bash nano shell Lets do something practical. We will automate the creation (and deletion) of user accounts on our system. First, create

Script 3

Using bash nano shell

Lets do something practical. We will automate the creation (and deletion) of user accounts on our system.

First, create an array of users (you need to have at least 5 users in your array). The username itself is up to you. Just make sure the names are appropriate for a child under 10 to read.

Here is the syntax for defining an array with two elements:

userlist[0]="user1"

userlist[1]="user2"

Here, userlist is the variable (that is actually an array). It contains data, in this case strings, that can be accessed using an array index, where the array index is simply a number. Note that there is NO SPACE before or after the equal sign

Another way to declare the array is to:

userlist=("user1" "user2")

Now, if I wanted to output the 2nd user, I would do:

echo ${userlist[1]}

Note that array numbering starts at 0, not 1! The second element of the array is indexed using 1the third would be index 2, and so on. This is a common paradigm in most programming languages.

Now, recall from a previous assignment that the user creation command is useradd.

For this portion, you must do the following:

Create an array that contains at least 5 usernames

Create a for loop that prints each username to the console

Create another for loop that adds each user to the system (note: you can combine (2) and (3) if you want)

Demonstrate that the users have been added to the system (hint: you did this in HW2)

Name this script _Script3_a.sh, and any output save as _Script3_a_Output.txt

Copy the file you just created, but name it _Script3_b.sh

(use the cp command)

Now, instead of adding users, delete the users from your system (hint: pass the r flag to the appropriate user deletion command you also did this in HW2)

Again, demonstrate that (a) the users are no longer on the system and (b) their user directories are gone

Name this script _Script3_b.sh, and any output save as _Script3_b_Output.txt

send the answer with photos please

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle Database Architecture

Authors: Thomas Kyte, Darl Kuhn

3rd Edition

1430262990, 9781430262992

More Books

Students also viewed these Databases questions

Question

Ty e2y Evaluate the integral dy

Answered: 1 week ago