Usetutoringspotscode to get 8% OFF on your first order!

Assignment 1: Bash Scripting

QUESTION 2
Write a bash script that monitors in real time the sizes of regular files in a specified folders. The folder name should be provided as an argument when calling the script. The folder must exist in the same working directory where the script is located. Ensure that the script is properly called with an argument. Then monitor the file sizes and log in a separate file the timestamp and the name of the file when its size goes above 4Kbytes. In such a case, archive and backup the file with the timestamp as part of the archives name and replace the file with a new and empty one. Exclude the log file from the monitoring. To test the script, manually create a folder with a mixture of sub-folders and files. When the script is running, open the files in your test folder and be adding content to it to increase the file size and check if your script could monitor the changes. (You are free to automate the testing). Properly comment your code.

QUESTION 3
Write a bash script that automates the creation and deletion of user accounts. The script should accept as input argument, a file containing a list of user names to be created on the system. Enforce that the user provides this input file while executing the script. The script should check if the usernames already exist on the system before creating the accounts. If a user account exit, the script should notify the user and skip that user name to the next one. Make sure to create a home directory as well. When the input list has been exhausted and all the user account created, output the content of /etc/passwd file and /home directory to the terminal for verification. In a next step, the script should ask if user wants to delete the newly created accounts? If yes, the script should delete the accounts including their home directories and output again the content of /etc/passwd file and /home directory for verification. If no, the script should terminate with appropriate message. This script is to be tested/executed as a root user. Properly comment your code.

You can leave a response, or trackback from your own site.

Leave a Reply

Powered by WordPress | Designed by: Premium WordPress Themes | Thanks to Themes Gallery, Bromoney and Wordpress Themes