Demonstrate your script execution on your laptop to the professor during your scheduled lab periods and submit your completed lab on Brightspace before the due date.

computer science

Description

Linux Shell Scripting II


 

Submission

Demonstrate your script execution on your laptop to the professor during your scheduled lab periods and submit your completed lab on Brightspace before the due date.

 

Procedure

 

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

 

1.     You will create a script file called myscript using vim.

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

3.      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

4.      Your script file should be properly commented.

5.      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.

 

A)      Create a user account

B)      Delete a user account

C)      Change supplementary group for a user account

D)      Change initial group for a user account

E)      Change default login shell for a user account

F)      Change account expiration date for a user account

Q)   Quit

 

6.      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.

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

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

9.      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

10.   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

11.   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

12.   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.

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

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

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

16.   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:


Related Questions in computer science category