Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You will create a script file for the purpose of user and group management in Li

ID: 3682511 • Letter: Y

Question

You will create a script file for the purpose of user and group management in Linux.

You will create a script file called myscript using vim.

The first line of each of your script file should force the use of the bash shell.

On the top of the script file, there should be a section of comments that contains the Assignment number, your name, student number, lab section number, name of the script file, the date, and a description of what the script file does

Your script file should be properly commented.

It should contain a menu that gives the user a choice of five items labeled A - F and

Q, and a prompt asking for what the user’s choice is.

Create a user account

Delete a user account

Change supplementary group for a user account

Change initial group for a user account

Change default login shell for a user account

Change account expiration date for a user account

Quit

This script file must loop using a while loop. When you run it, you can choose one menu item. A message should be displayed if an invalid option is chosen.

The menu choice should be decoded using an if-elif-else structure.

The if structure should accept upper or lower case letters. Use || operator to allow upper or lower case characters.

If A or a is chosen, the script should prompt you to enter the following information:

Username

User’s home directory

Default login shell

Create the user account based on the information given above

If B or b is chosen, it should prompt you for username of the account to be deleted, and delete the user account as well as the user’s home directory

If C or c is chosen, it should prompt you for username and group name that is added as a supplementary group for the user account

If D or d is chosen, it should prompt you for username and group name that is used as the initial group for the user account, and change the initial group for the user account.

If E or e is chosen, it should prompt you for username and shell name, and change the default shell for the user account.

If F or f is chosen, it should prompt you for username and expiration date, and change the expiration date for the user account.

If Q or q is chosen, the script should end.

It should sleep for 3 seconds after each menu item is selected before the loop causes the menu to be redisplayed

Below is a sample of a while loop:

choice=n

#initialize to

dummy

value

while [

$choice != "Q"

] &&

[ $choice !=   "q"   ]

do

clear

echo -e "Choice: c" read choice

echo "You Entered $choice." sleep 3

done

choice=n

#initialize to

dummy

value

while [

$choice != "Q"

] &&

[ $choice !=   "q"   ]

Explanation / Answer

#!/bin/bash

# My script

#Assignment Number :150

#Name :John

#Student Number :786

#labSection Number :1CS

#Name of the Scriptfile : UserGroup

#Date :03/28/2016

#while loop for repeat process

set ch="A"

while ($ch!="")

     echo -n "Please Enter your Choice"

     set ch =$<

     if($ch!="") then

             echo "your selected choice is"   

      endif

end

#ch = 'Please Enter your Choice'

options = ("A","B","C","D","E","F","Quit")

select opt in "${options[@]}"

do

     case $opt in

            "A")

                echo "Create a user account"

                     ;;

            "B")

                echo "Delete a user account"

                     ;;

            "C")

                echo "Change supplementary group for a user account"

                    ;;

            "D")

               echo "Change initial group for a user account"

                   ;;

            "E")

               echo "Change default login shell for a user account"

                   ;;

            "F")

               echo "Change account expiration date for a user account"

                   ;;

            "Quit")

               break;

               ;;

             *) echo invalid option;;

        esac

done   

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote