Reference no: EM13347701
1. Menu options
The shell script should generate a menu to allow the user to choose each option. After executing options 16, the
script is expected to loop back to the Menu to allow further actions.
2. a) List system users
b) List nonsystem users
For above 2 options, your script should automatically look in the /etc/password file for system users and nonsystem users.
System users and nonsystem users are defined in /etc/login.defs file. In general, system users are users with UID less than 1000 and nonsystem 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 nonsystem 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 password file and report statistics of disk usage of each nonsystem user.
4. d) [Help Functions] Generate 5 core files randomly in at least 3 normal users directories.
e) Detect and report core files in nonsystem user directories
f) Remove core files in nonsystem 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 nonsystem users' directories. For this option check the shell command touch. This is a help function for testing option e and f.
In order to get full 1.5 marks, the path of core file generation needs to be randomized.
For option e), the script traverses through nonsystem users' directories, locates core files and their absolute path.
It needs to generate a report to the console. The report format can be {nonsystem 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, nonsystem 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.