You now need to write a script for user maintenance. Write a script that will perform the following tasks: Prompt the system administrator for all valid input parameters Generate a menu to ask which task is needed to be performed Create a UNIX group Drop a UNIX group Create a user Drop a user Note that as part of the Create User section, a UNIX group many be identified that does not already exist, so that group will need to be created as part of the process. A third script that you need to write will kill all of the processes associated with a user. The following are the requirements: Prompt the system administrator for the target user name List the running processes for that user Confirm with the system administrator before killing the processes Kill the processes after confirmation It is very important to note with this task that you should only kill processes for a user and his or her running processes; do not arbitrarily kill running daemons. Include a discussion about the difference between user processes and daemons. What are daemons, and what are they used for? What are the consequences of killing a daemon using this script?

Script for User Maintenance

#!/bin/bash

# Function to create a UNIX group
create_group() {
read -p “Enter the name of the group to create: ” group_name
groupadd $group_name
}

# Function to drop a UNIX group
drop_group() {
read -p “Enter the name of the group to drop: ” group_name
groupdel $group_name
}

# Function to create a user and group if necessary
create_user() {
read -p “Enter the name of the user to create: ” user_name
read -p “Enter the name of the group for the user: ” group_name

# Check if the group already exists
if ! grep -q $group_name /etc/group; then
echo “Creating group: $group_name”
groupadd $group_name
fi

echo “Creating user: $user_name”
useradd -g $group_name $user_name
}

# Function to drop a user
drop_user() {
read -p “Enter the name of the user to drop: ” user_name
userdel $user_name
}

# Main menu
while true; do
echo “1. Create a UNIX group”
echo “2. Drop a UNIX group”
echo “3. Create a user”
echo “4. Drop a user”
echo “5. Exit”

read -p “Enter your choice: ” choice

case $choice in
1) create_group ;;
2) drop_group ;;
3) create_user ;;
4) drop_user ;;
5) exit ;;
*) echo “Invalid choice. Please try again.” ;;
esac
done

Script for killing user processes

#!/bin/bash

# Function to list running processes for a user
list_processes() {
read -p “Enter the target user name: ” user_name
ps -u $user_name
}

# Function to kill running processes for a user
kill_processes() {
read -p “Enter the target user name: ” user_name

echo “The following processes are running for the user: $user_name”
ps -u $user_name

read -p “Are you sure you want to kill these processes? (y/n): ” confirm

if [ $confirm == “y” ]; then
pkill -u $user_name
echo “Processes killed successfully.”
else
echo “Processes not killed.”
fi
}

# Main menu
while true; do
echo “1. List running processes for a user”
echo “2. Kill processes for a user”
echo “3. Exit”

read -p “Enter your choice: ” choice

case $choice in
1) list_processes ;;
2) kill_processes ;;
3) exit ;;
*) echo “Invalid choice. Please try again.” ;;
esac
done

Discussion:

In the context of system administration, user processes and daemons are two distinct types of running processes.

User processes are created by regular users when they execute programs or tasks on a system. These processes are associated with the user who initiated them and have limited privileges. They typically interact with the user’s environment and perform tasks on behalf of the user. Examples of user processes include running a command in the terminal or executing an application.

Daemons, on the other hand, are background processes that run independently of user interactions. They are typically started during system boot and continue running until the system shuts down. Daemons are often responsible for providing services or performing tasks that do not require user intervention. Examples of daemons include web servers, database servers, and system monitoring tools.

Killing a user process using the provided script will terminate the specific process associated with the user. This action can be useful in situations where a user process becomes unresponsive or consumes excessive resources. However, it is important to note that killing a daemon using this script can have severe consequences.

Daemons are designed to run continuously and serve specific functions for the system. Killing a daemon abruptly can result in service disruptions, data corruption, or system instability. It is recommended to use proper administrative tools and methods to manage and control daemons, rather than relying on generic process termination scripts.

In summary, user processes are created by users and serve their individual tasks, while daemons are background processes that provide system services. Killing a user process helps resolve specific issues with that process, while killing a daemon can have serious consequences on system functionality. System administrators should exercise caution and consider the impact before terminating any running processes.

Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadline.


Click Here to Make an Order Click Here to Hire a Writer