Writing a shell script named sysmanage


Overall requirements:

For this assignment, your task is to write a shell script named sysManage, which goes through the home directories in a Unix/Linux System and conducts the following menu operations:

a) List system users

b) List non­system users

c) Report on non­system user disk usage

d) [Testing Function] Generate 5 core files randomly in at least 3 normal users directories.

e) Detect and report core files in non­system user directories

f) Remove core files in non­system user directories

x) Exit

Detail explanation

1. Menu options

The shell script should generate a menu to allow the user to choose each option. After executing options 1­6, the script is expected to loop back to the Menu to allow further actions.

2. a) List system users

b) List non­system users

For above 2 options, your script should automatically look in the /etc/password file for system users and non­system users.

System users and non­system users are defined in /etc/login.defs file. In general, system users are users with UID less than 1000 and non­system users are users with UID between 1000 and 6000. Following is an example

/etc/login.defs file.
# Min/max values for automatic uid selection in useradd
UID_MIN                  1000
UID_MAX                 60000
# System accounts
#SYS_UID_MIN              100
#SYS_UID_MAX              999

The output of the a) and b) should include {Total number of users, User Names}.

3. c) Report on non­system user disk usage

The output should contain the following information:

{Username, total_no_of_directories, total_number_of_files, total_size}

For this option, the script is expected to traverse through each user home directory specified in /etc/password file and report statistics of disk usage of each non­system user.

4. d) [Help Functions] Generate 5 core files randomly in at least 3 normal users directories.

e) Detect and report core files in non­system user directories

f) Remove core files in non­system user directories core files (program memory dumps) are created when a program terminates involuntarily in UNIX like systems.

The file name is always 'core'. It is preferred to clean out all of the core files in the system as they are waste of storage.

For option d), the script needs to generate 5 empty files with file name core randomly in at least 3 non­system users’ directories. For this option check the shell command touch. This is a help function for testing option e and f.

For option e), the script traverses through non­system users’ directories, locates core files and their absolute path. It needs to generate a report to the console.  The report format can be {non­system user name, core file with full absolute path, core file size, core file timestamp}.

For option f), the script removes the core file and write the action into a log.txt file in append mode. The script expects to generate deletion information of the log files and then write deletion information into a log.txt file. The format can be {timestamp of deletion, non­system user name, core file name with full absolute path, core file size, core file timestamp}

5.  x) Exit.
The script is expected to quit after user click x.

Request for Solution File

Ask an Expert for Answer!!
Operating System: Writing a shell script named sysmanage
Reference No:- TGS01679

Expected delivery within 24 Hours